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. API-Since: 2.0

    • Constructor Detail

      • NSURLRequest

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

      • accessInstanceVariablesDirectly

        public static boolean accessInstanceVariablesDirectly()
      • allocWithZone

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

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

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

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

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

        @NotNull
        public static @NotNull 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

        @NotNull
        public static @NotNull NSSet<java.lang.String> keyPathsForValuesAffectingValueForKey​(@NotNull
                                                                                             @NotNull java.lang.String key)
      • requestWithURL

        public static NSURLRequest requestWithURL​(@NotNull
                                                  @NotNull 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​(@NotNull
                                                                            @NotNull 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

        @Nullable
        public @Nullable 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

        @Nullable
        public @Nullable 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

        @Nullable
        public @Nullable 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. API-Since: 4.0
      • URL

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

        @Nullable
        public @Nullable 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 satisfy the request, NO otherwise. API-Since: 6.0
      • cachePolicy

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

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

        public NSURLRequest initWithURL​(@NotNull
                                        @NotNull 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​(@NotNull
                                                                  @NotNull 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

        @Nullable
        public @Nullable NSURL mainDocumentURL()
        The main document URL associated with this load. This URL is used for the cookie "same domain as main document" policy, and attributing the request as a sub-resource of a user-specified URL. There may also be other future uses. See setMainDocumentURL:
        Returns:
        The main document URL.
      • mutableCopyWithZone

        @NotNull
        public @NotNull java.lang.Object mutableCopyWithZone​(@Nullable
                                                             @Nullable 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. API-Since: 4.0
      • _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 allotted 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

        @Nullable
        public @Nullable java.lang.String valueForHTTPHeaderField​(@NotNull
                                                                  @NotNull 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 satisfy the request, NO otherwise. API-Since: 13.0
      • 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 satisfy the request, NO otherwise. API-Since: 13.0
      • assumesHTTP3Capable

        public boolean assumesHTTP3Capable()
        returns whether we assume that server supports HTTP/3. Enables QUIC racing without HTTP/3 service discovery.
        Returns:
        YES if server endpoint is known to support HTTP/3. Defaults to NO. The default may be YES in a future OS update. API-Since: 14.5
      • attribution

        public long attribution()
        Returns the NSURLRequestAttribution associated with this request. This will return NSURLRequestAttributionDeveloper for requests that have not explicitly set an attribution.
        Returns:
        The NSURLRequestAttribution associated with this request. API-Since: 15.0
      • requiresDNSSECValidation

        public boolean requiresDNSSECValidation()
        sets whether a request is required to do DNSSEC validation during DNS lookup. YES, if the DNS lookup for this request should require DNSSEC validation, No otherwise. Defaults to NO. API-Since: 16.1
      • useStoredAccessor

        @Deprecated
        public static boolean useStoredAccessor()
        Deprecated.