Class NSURLRequest

  • All Implemented Interfaces:
    NSCoding, NSCopying, NSMutableCopying, NSSecureCoding, NSObject
    Direct Known Subclasses:
    NSMutableURLRequest

    public class NSURLRequest
    extends NSObject
    implements NSSecureCoding, NSCopying, NSMutableCopying
    NSURLRequest An NSURLRequest object represents a URL load request in a manner independent of protocol and URL scheme. NSURLRequest encapsulates two basic data elements about a URL load request:
    • The URL to load.
    • The policy to use when consulting the URL content cache made available by the implementation.
    In addition, NSURLRequest is designed to be extended to support protocol-specific data by adding categories to access a property object provided in an interface targeted at protocol implementors.
    • Protocol implementors should direct their attention to the NSURLRequestExtensibility category on NSURLRequest for more information on how to provide extensions on NSURLRequest to support protocol-specific request information.
    • Clients of this API who wish to create NSURLRequest objects to load URL content should consult the protocol-specific NSURLRequest categories that are available. The NSHTTPURLRequest category on NSURLRequest is an example.

    Objects of this class are used to create NSURLConnection instances, which can are used to perform the load of a URL, or as input to the NSURLConnection class method which performs synchronous loads.

    • Constructor Detail

      • NSURLRequest

        protected NSURLRequest​(org.moe.natj.general.Pointer peer)
    • Method Detail

      • accessInstanceVariablesDirectly

        public static boolean accessInstanceVariablesDirectly()
      • allocWithZone

        public static java.lang.Object allocWithZone​(org.moe.natj.general.ptr.VoidPtr zone)
      • automaticallyNotifiesObserversForKey

        public static boolean automaticallyNotifiesObserversForKey​(java.lang.String key)
      • cancelPreviousPerformRequestsWithTarget

        public static void cancelPreviousPerformRequestsWithTarget​(java.lang.Object aTarget)
      • cancelPreviousPerformRequestsWithTargetSelectorObject

        public static void cancelPreviousPerformRequestsWithTargetSelectorObject​(java.lang.Object aTarget,
                                                                                 org.moe.natj.objc.SEL aSelector,
                                                                                 java.lang.Object anArgument)
      • classFallbacksForKeyedArchiver

        public static NSArray<java.lang.String> classFallbacksForKeyedArchiver()
      • classForKeyedUnarchiver

        public static org.moe.natj.objc.Class classForKeyedUnarchiver()
      • debugDescription_static

        public static java.lang.String debugDescription_static()
      • description_static

        public static java.lang.String description_static()
      • hash_static

        public static long hash_static()
      • instanceMethodSignatureForSelector

        public static NSMethodSignature instanceMethodSignatureForSelector​(org.moe.natj.objc.SEL aSelector)
      • instancesRespondToSelector

        public static boolean instancesRespondToSelector​(org.moe.natj.objc.SEL aSelector)
      • isSubclassOfClass

        public static boolean isSubclassOfClass​(org.moe.natj.objc.Class aClass)
      • keyPathsForValuesAffectingValueForKey

        public static NSSet<java.lang.String> keyPathsForValuesAffectingValueForKey​(java.lang.String key)
      • new_objc

        public static java.lang.Object new_objc()
      • requestWithURL

        public static NSURLRequest requestWithURL​(NSURL URL)
        requestWithURL: Allocates and initializes an NSURLRequest with the given URL. Default values are used for cache policy (NSURLRequestUseProtocolCachePolicy) and timeout interval (60 seconds).
        Parameters:
        URL - The URL for the request.
        Returns:
        A newly-created and autoreleased NSURLRequest instance.
      • requestWithURLCachePolicyTimeoutInterval

        public static NSURLRequest requestWithURLCachePolicyTimeoutInterval​(NSURL URL,
                                                                            long cachePolicy,
                                                                            double timeoutInterval)
        requestWithURL:cachePolicy:timeoutInterval: Allocates and initializes a NSURLRequest with the given URL and cache policy.
        Parameters:
        URL - The URL for the request.
        cachePolicy - The cache policy for the request.
        timeoutInterval - The timeout interval for the request. See the commentary for the timeoutInterval for more information on timeout intervals.
        Returns:
        A newly-created and autoreleased NSURLRequest instance.
      • resolveClassMethod

        public static boolean resolveClassMethod​(org.moe.natj.objc.SEL sel)
      • resolveInstanceMethod

        public static boolean resolveInstanceMethod​(org.moe.natj.objc.SEL sel)
      • setVersion_static

        public static void setVersion_static​(long aVersion)
      • superclass_static

        public static org.moe.natj.objc.Class superclass_static()
      • supportsSecureCoding

        public static boolean supportsSecureCoding()
      • version_static

        public static long version_static()
      • HTTPBody

        public NSData HTTPBody()
        Returns the request body data of the receiver. This data is sent as the message body of the request, as in done in an HTTP POST request.
        Returns:
        The request body data of the receiver.
      • HTTPBodyStream

        public NSInputStream HTTPBodyStream()
        Returns the request body stream of the receiver if any has been set The stream is returned for examination only; it is not safe for the caller to manipulate the stream in any way. Also note that the HTTPBodyStream and HTTPBody are mutually exclusive - only one can be set on a given request. Also note that the body stream is preserved across copies, but is LOST when the request is coded via the NSCoding protocol
        Returns:
        The request body stream of the receiver.
      • HTTPMethod

        public java.lang.String HTTPMethod()
        Returns the HTTP request method of the receiver.
        Returns:
        the HTTP request method of the receiver.
      • HTTPShouldHandleCookies

        public boolean HTTPShouldHandleCookies()
        Determine whether default cookie handling will happen for this request. NOTE: This value is not used prior to 10.3
        Returns:
        YES if cookies will be sent with and set for this request; otherwise NO.
      • HTTPShouldUsePipelining

        public boolean HTTPShouldUsePipelining()
        Reports whether the receiver is not expected to wait for the previous response before transmitting.
        Returns:
        YES if the receiver should transmit before the previous response is received. NO if the receiver should wait for the previous response before transmitting.
      • URL

        public NSURL URL()
        Returns the URL of the receiver.
        Returns:
        The URL of the receiver.
      • allHTTPHeaderFields

        public NSDictionary<java.lang.String,​java.lang.String> allHTTPHeaderFields()
        Returns a dictionary containing all the HTTP header fields of the receiver.
        Returns:
        a dictionary containing all the HTTP header fields of the receiver.
      • allowsCellularAccess

        public boolean allowsCellularAccess()
        returns whether a connection created with this request is allowed to use the built in cellular radios (if present).
        Returns:
        YES if the receiver is allowed to use the built in cellular radios to satify the request, NO otherwise.
      • cachePolicy

        public long cachePolicy()
        Returns the cache policy of the receiver.
        Returns:
        The cache policy of the receiver.
      • copyWithZone

        public java.lang.Object copyWithZone​(org.moe.natj.general.ptr.VoidPtr zone)
        Specified by:
        copyWithZone in interface NSCopying
      • initWithURL

        public NSURLRequest initWithURL​(NSURL URL)
        initWithURL: Initializes an NSURLRequest with the given URL. Default values are used for cache policy (NSURLRequestUseProtocolCachePolicy) and timeout interval (60 seconds).
        Parameters:
        URL - The URL for the request.
        Returns:
        An initialized NSURLRequest.
      • initWithURLCachePolicyTimeoutInterval

        public NSURLRequest initWithURLCachePolicyTimeoutInterval​(NSURL URL,
                                                                  long cachePolicy,
                                                                  double timeoutInterval)
        initWithURL: Initializes an NSURLRequest with the given URL and cache policy. This is the designated initializer for the NSURLRequest class.
        Parameters:
        URL - The URL for the request.
        cachePolicy - The cache policy for the request.
        timeoutInterval - The timeout interval for the request. See the commentary for the timeoutInterval for more information on timeout intervals.
        Returns:
        An initialized NSURLRequest.
      • mainDocumentURL

        public NSURL mainDocumentURL()
        The main document URL associated with this load. This URL is used for the cookie "same domain as main document" policy. There may also be other future uses. See setMainDocumentURL: NOTE: In the current implementation, this value is unused by the framework. A fully functional version of this method will be available in the future.
        Returns:
        The main document URL.
      • mutableCopyWithZone

        public java.lang.Object mutableCopyWithZone​(org.moe.natj.general.ptr.VoidPtr zone)
        Specified by:
        mutableCopyWithZone in interface NSMutableCopying
      • networkServiceType

        public long networkServiceType()
        Returns the NSURLRequestNetworkServiceType associated with this request. This will return NSURLNetworkServiceTypeDefault for requests that have not explicitly set a networkServiceType (using the setNetworkServiceType method).
        Returns:
        The NSURLRequestNetworkServiceType associated with this request.
      • _supportsSecureCoding

        public boolean _supportsSecureCoding()
        Description copied from interface: NSSecureCoding
        This property must return YES on all classes that allow secure coding. Subclasses of classes that adopt NSSecureCoding and override initWithCoder: must also override this method and return YES. The Secure Coding Guide should be consulted when writing methods that decode data.
        Specified by:
        _supportsSecureCoding in interface NSSecureCoding
      • timeoutInterval

        public double timeoutInterval()
        Returns the timeout interval of the receiver. The timeout interval specifies the limit on the idle interval alloted to a request in the process of loading. The "idle interval" is defined as the period of time that has passed since the last instance of load activity occurred for a request that is in the process of loading. Hence, when an instance of load activity occurs (e.g. bytes are received from the network for a request), the idle interval for a request is reset to 0. If the idle interval ever becomes greater than or equal to the timeout interval, the request is considered to have timed out. This timeout interval is measured in seconds.
        Returns:
        The timeout interval of the receiver.
      • valueForHTTPHeaderField

        public java.lang.String valueForHTTPHeaderField​(java.lang.String field)
        valueForHTTPHeaderField: Returns the value which corresponds to the given header field. Note that, in keeping with the HTTP RFC, HTTP header field names are case-insensitive.
        Parameters:
        field - the header field name to use for the lookup (case-insensitive).
        Returns:
        the value associated with the given header field, or nil if there is no value associated with the given header field.
      • allowsConstrainedNetworkAccess

        public boolean allowsConstrainedNetworkAccess()
        returns whether a connection created with this request is allowed to use network interfaces which have been marked as constrained.
        Returns:
        YES if the receiver is allowed to use an interface marked as constrained to satify the request, NO otherwise.
      • allowsExpensiveNetworkAccess

        public boolean allowsExpensiveNetworkAccess()
        returns whether a connection created with this request is allowed to use network interfaces which have been marked as expensive.
        Returns:
        YES if the receiver is allowed to use an interface marked as expensive to satify the request, NO otherwise.