objc2_foundation/generated/
NSURLRequest.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6
7use crate::*;
8
9/// The NSURLRequestCachePolicy enum defines constants that
10/// can be used to specify the type of interactions that take place with
11/// the caching system when the URL loading system processes a request.
12/// Specifically, these constants cover interactions that have to do
13/// with whether already-existing cache data is returned to satisfy a
14/// URL load request.
15///
16///
17/// caching logic defined in the protocol implementation, if any, is
18/// used for a particular URL load request. This is the default policy
19/// for URL load requests.
20///
21///
22/// data for the URL load should be loaded from the origin source. No
23/// existing local cache data, regardless of its freshness or validity,
24/// should be used to satisfy a URL load request.
25///
26///
27/// not only should the local cache data be ignored, but that proxies and
28/// other intermediates should be instructed to disregard their caches
29/// so far as the protocol allows.
30///
31///
32/// NSURLRequestReloadIgnoringLocalCacheData.
33///
34///
35/// existing cache data should be used to satisfy a URL load request,
36/// regardless of its age or expiration date. However, if there is no
37/// existing data in the cache corresponding to a URL load request,
38/// the URL is loaded from the origin source.
39///
40///
41/// existing cache data should be used to satisfy a URL load request,
42/// regardless of its age or expiration date. However, if there is no
43/// existing data in the cache corresponding to a URL load request, no
44/// attempt is made to load the URL from the origin source, and the
45/// load is considered to have failed. This constant specifies a
46/// behavior that is similar to an "offline" mode.
47///
48///
49/// the existing cache data may be used provided the origin source
50/// confirms its validity, otherwise the URL is loaded from the
51/// origin source.
52///
53/// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlrequestcachepolicy?language=objc)
54// NS_ENUM
55#[repr(transparent)]
56#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
57pub struct NSURLRequestCachePolicy(pub NSUInteger);
58impl NSURLRequestCachePolicy {
59    #[doc(alias = "NSURLRequestUseProtocolCachePolicy")]
60    pub const UseProtocolCachePolicy: Self = Self(0);
61    #[doc(alias = "NSURLRequestReloadIgnoringLocalCacheData")]
62    pub const ReloadIgnoringLocalCacheData: Self = Self(1);
63    #[doc(alias = "NSURLRequestReloadIgnoringLocalAndRemoteCacheData")]
64    pub const ReloadIgnoringLocalAndRemoteCacheData: Self = Self(4);
65    #[doc(alias = "NSURLRequestReloadIgnoringCacheData")]
66    pub const ReloadIgnoringCacheData: Self =
67        Self(NSURLRequestCachePolicy::ReloadIgnoringLocalCacheData.0);
68    #[doc(alias = "NSURLRequestReturnCacheDataElseLoad")]
69    pub const ReturnCacheDataElseLoad: Self = Self(2);
70    #[doc(alias = "NSURLRequestReturnCacheDataDontLoad")]
71    pub const ReturnCacheDataDontLoad: Self = Self(3);
72    #[doc(alias = "NSURLRequestReloadRevalidatingCacheData")]
73    pub const ReloadRevalidatingCacheData: Self = Self(5);
74}
75
76unsafe impl Encode for NSURLRequestCachePolicy {
77    const ENCODING: Encoding = NSUInteger::ENCODING;
78}
79
80unsafe impl RefEncode for NSURLRequestCachePolicy {
81    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
82}
83
84/// The NSURLRequestNetworkServiceType enum defines constants that
85/// can be used to specify the service type to associate with this request.  The
86/// service type is used to provide the networking layers a hint of the purpose
87/// of the request.
88///
89///
90/// when created.  This value should be left unchanged for the vast majority of requests.
91///
92///
93/// control traffic.
94///
95///
96/// traffic.
97///
98///
99/// traffic (such as a file download).
100///
101/// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlrequestnetworkservicetype?language=objc)
102// NS_ENUM
103#[repr(transparent)]
104#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
105pub struct NSURLRequestNetworkServiceType(pub NSUInteger);
106impl NSURLRequestNetworkServiceType {
107    #[doc(alias = "NSURLNetworkServiceTypeDefault")]
108    pub const NetworkServiceTypeDefault: Self = Self(0);
109    #[deprecated = "Use PushKit for VoIP control purposes"]
110    #[doc(alias = "NSURLNetworkServiceTypeVoIP")]
111    pub const NetworkServiceTypeVoIP: Self = Self(1);
112    #[doc(alias = "NSURLNetworkServiceTypeVideo")]
113    pub const NetworkServiceTypeVideo: Self = Self(2);
114    #[doc(alias = "NSURLNetworkServiceTypeBackground")]
115    pub const NetworkServiceTypeBackground: Self = Self(3);
116    #[doc(alias = "NSURLNetworkServiceTypeVoice")]
117    pub const NetworkServiceTypeVoice: Self = Self(4);
118    #[doc(alias = "NSURLNetworkServiceTypeResponsiveData")]
119    pub const NetworkServiceTypeResponsiveData: Self = Self(6);
120    #[doc(alias = "NSURLNetworkServiceTypeAVStreaming")]
121    pub const NetworkServiceTypeAVStreaming: Self = Self(8);
122    #[doc(alias = "NSURLNetworkServiceTypeResponsiveAV")]
123    pub const NetworkServiceTypeResponsiveAV: Self = Self(9);
124    #[doc(alias = "NSURLNetworkServiceTypeCallSignaling")]
125    pub const NetworkServiceTypeCallSignaling: Self = Self(11);
126}
127
128unsafe impl Encode for NSURLRequestNetworkServiceType {
129    const ENCODING: Encoding = NSUInteger::ENCODING;
130}
131
132unsafe impl RefEncode for NSURLRequestNetworkServiceType {
133    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
134}
135
136/// The NSURLRequestAttribution enum is used to indicate whether the
137/// user or developer specified the URL.
138///
139///
140/// by the developer. This is the default value for an NSURLRequest when created.
141///
142///
143/// the user.
144///
145/// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlrequestattribution?language=objc)
146// NS_ENUM
147#[repr(transparent)]
148#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
149pub struct NSURLRequestAttribution(pub NSUInteger);
150impl NSURLRequestAttribution {
151    #[doc(alias = "NSURLRequestAttributionDeveloper")]
152    pub const Developer: Self = Self(0);
153    #[doc(alias = "NSURLRequestAttributionUser")]
154    pub const User: Self = Self(1);
155}
156
157unsafe impl Encode for NSURLRequestAttribution {
158    const ENCODING: Encoding = NSUInteger::ENCODING;
159}
160
161unsafe impl RefEncode for NSURLRequestAttribution {
162    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
163}
164
165extern_class!(
166    /// An NSURLRequest object represents a URL load request in a
167    /// manner independent of protocol and URL scheme.
168    ///
169    ///
170    /// NSURLRequest encapsulates two basic data elements about
171    /// a URL load request:
172    /// <ul>
173    /// <li>
174    /// The URL to load.
175    /// <li>
176    /// The policy to use when consulting the URL content cache made
177    /// available by the implementation.
178    /// </ul>
179    /// In addition, NSURLRequest is designed to be extended to support
180    /// protocol-specific data by adding categories to access a property
181    /// object provided in an interface targeted at protocol implementors.
182    /// <ul>
183    /// <li>
184    /// Protocol implementors should direct their attention to the
185    /// NSURLRequestExtensibility category on NSURLRequest for more
186    /// information on how to provide extensions on NSURLRequest to
187    /// support protocol-specific request information.
188    /// <li>
189    /// Clients of this API who wish to create NSURLRequest objects to
190    /// load URL content should consult the protocol-specific NSURLRequest
191    /// categories that are available. The NSHTTPURLRequest category on
192    /// NSURLRequest is an example.
193    /// </ul>
194    /// <p>
195    /// Objects of this class are used to create NSURLConnection instances,
196    /// which can are used to perform the load of a URL, or as input to the
197    /// NSURLConnection class method which performs synchronous loads.
198    ///
199    /// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlrequest?language=objc)
200    #[unsafe(super(NSObject))]
201    #[derive(Debug, PartialEq, Eq, Hash)]
202    pub struct NSURLRequest;
203);
204
205#[cfg(feature = "NSObject")]
206unsafe impl NSCoding for NSURLRequest {}
207
208#[cfg(feature = "NSObject")]
209unsafe impl NSCopying for NSURLRequest {}
210
211#[cfg(feature = "NSObject")]
212unsafe impl CopyingHelper for NSURLRequest {
213    type Result = Self;
214}
215
216#[cfg(feature = "NSObject")]
217unsafe impl NSMutableCopying for NSURLRequest {}
218
219#[cfg(feature = "NSObject")]
220unsafe impl MutableCopyingHelper for NSURLRequest {
221    type Result = NSMutableURLRequest;
222}
223
224unsafe impl NSObjectProtocol for NSURLRequest {}
225
226#[cfg(feature = "NSObject")]
227unsafe impl NSSecureCoding for NSURLRequest {}
228
229impl NSURLRequest {
230    extern_methods!(
231        #[cfg(feature = "NSURL")]
232        /// Allocates and initializes an NSURLRequest with the given
233        /// URL.
234        ///
235        /// Default values are used for cache policy
236        /// (NSURLRequestUseProtocolCachePolicy) and timeout interval (60
237        /// seconds).
238        ///
239        /// Parameter `URL`: The URL for the request.
240        ///
241        /// Returns: A newly-created and autoreleased NSURLRequest instance.
242        #[unsafe(method(requestWithURL:))]
243        #[unsafe(method_family = none)]
244        pub unsafe fn requestWithURL(url: &NSURL) -> Retained<Self>;
245
246        /// Indicates that NSURLRequest implements the NSSecureCoding protocol.
247        ///
248        /// Returns: A BOOL value set to YES.
249        #[unsafe(method(supportsSecureCoding))]
250        #[unsafe(method_family = none)]
251        pub unsafe fn supportsSecureCoding() -> bool;
252
253        #[cfg(all(feature = "NSDate", feature = "NSURL"))]
254        /// Allocates and initializes a NSURLRequest with the given
255        /// URL and cache policy.
256        ///
257        /// Parameter `URL`: The URL for the request.
258        ///
259        /// Parameter `cachePolicy`: The cache policy for the request.
260        ///
261        /// Parameter `timeoutInterval`: The timeout interval for the request. See the
262        /// commentary for the
263        /// <tt>
264        /// timeoutInterval
265        /// </tt>
266        /// for more information on
267        /// timeout intervals.
268        ///
269        /// Returns: A newly-created and autoreleased NSURLRequest instance.
270        #[unsafe(method(requestWithURL:cachePolicy:timeoutInterval:))]
271        #[unsafe(method_family = none)]
272        pub unsafe fn requestWithURL_cachePolicy_timeoutInterval(
273            url: &NSURL,
274            cache_policy: NSURLRequestCachePolicy,
275            timeout_interval: NSTimeInterval,
276        ) -> Retained<Self>;
277
278        #[cfg(feature = "NSURL")]
279        /// Initializes an NSURLRequest with the given URL.
280        ///
281        /// Default values are used for cache policy
282        /// (NSURLRequestUseProtocolCachePolicy) and timeout interval (60
283        /// seconds).
284        ///
285        /// Parameter `URL`: The URL for the request.
286        ///
287        /// Returns: An initialized NSURLRequest.
288        #[unsafe(method(initWithURL:))]
289        #[unsafe(method_family = init)]
290        pub unsafe fn initWithURL(this: Allocated<Self>, url: &NSURL) -> Retained<Self>;
291
292        #[cfg(all(feature = "NSDate", feature = "NSURL"))]
293        /// Initializes an NSURLRequest with the given URL and
294        /// cache policy.
295        ///
296        /// This is the designated initializer for the
297        /// NSURLRequest class.
298        ///
299        /// Parameter `URL`: The URL for the request.
300        ///
301        /// Parameter `cachePolicy`: The cache policy for the request.
302        ///
303        /// Parameter `timeoutInterval`: The timeout interval for the request. See the
304        /// commentary for the
305        /// <tt>
306        /// timeoutInterval
307        /// </tt>
308        /// for more information on
309        /// timeout intervals.
310        ///
311        /// Returns: An initialized NSURLRequest.
312        #[unsafe(method(initWithURL:cachePolicy:timeoutInterval:))]
313        #[unsafe(method_family = init)]
314        pub unsafe fn initWithURL_cachePolicy_timeoutInterval(
315            this: Allocated<Self>,
316            url: &NSURL,
317            cache_policy: NSURLRequestCachePolicy,
318            timeout_interval: NSTimeInterval,
319        ) -> Retained<Self>;
320
321        #[cfg(feature = "NSURL")]
322        /// Returns the URL of the receiver.
323        ///
324        /// Returns: The URL of the receiver.
325        #[unsafe(method(URL))]
326        #[unsafe(method_family = none)]
327        pub unsafe fn URL(&self) -> Option<Retained<NSURL>>;
328
329        /// Returns the cache policy of the receiver.
330        ///
331        /// Returns: The cache policy of the receiver.
332        #[unsafe(method(cachePolicy))]
333        #[unsafe(method_family = none)]
334        pub unsafe fn cachePolicy(&self) -> NSURLRequestCachePolicy;
335
336        #[cfg(feature = "NSDate")]
337        /// Returns the timeout interval of the receiver.
338        ///
339        /// The timeout interval specifies the limit on the idle
340        /// interval allotted to a request in the process of loading. The "idle
341        /// interval" is defined as the period of time that has passed since the
342        /// last instance of load activity occurred for a request that is in the
343        /// process of loading. Hence, when an instance of load activity occurs
344        /// (e.g. bytes are received from the network for a request), the idle
345        /// interval for a request is reset to 0. If the idle interval ever
346        /// becomes greater than or equal to the timeout interval, the request
347        /// is considered to have timed out. This timeout interval is measured
348        /// in seconds.
349        ///
350        /// Returns: The timeout interval of the receiver.
351        #[unsafe(method(timeoutInterval))]
352        #[unsafe(method_family = none)]
353        pub unsafe fn timeoutInterval(&self) -> NSTimeInterval;
354
355        #[cfg(feature = "NSURL")]
356        /// The main document URL associated with this load.
357        ///
358        /// This URL is used for the cookie "same domain as main
359        /// document" policy, and attributing the request as a sub-resource
360        /// of a user-specified URL. There may also be other future uses.
361        /// See setMainDocumentURL:
362        ///
363        /// Returns: The main document URL.
364        #[unsafe(method(mainDocumentURL))]
365        #[unsafe(method_family = none)]
366        pub unsafe fn mainDocumentURL(&self) -> Option<Retained<NSURL>>;
367
368        /// Returns the NSURLRequestNetworkServiceType associated with this request.
369        ///
370        /// This will return NSURLNetworkServiceTypeDefault for requests that have
371        /// not explicitly set a networkServiceType (using the setNetworkServiceType method).
372        ///
373        /// Returns: The NSURLRequestNetworkServiceType associated with this request.
374        #[unsafe(method(networkServiceType))]
375        #[unsafe(method_family = none)]
376        pub unsafe fn networkServiceType(&self) -> NSURLRequestNetworkServiceType;
377
378        /// returns whether a connection created with this request is allowed to use
379        /// the built in cellular radios (if present).
380        ///
381        /// Returns: YES if the receiver is allowed to use the built in cellular radios to
382        /// satisfy the request, NO otherwise.
383        #[unsafe(method(allowsCellularAccess))]
384        #[unsafe(method_family = none)]
385        pub unsafe fn allowsCellularAccess(&self) -> bool;
386
387        /// returns whether a connection created with this request is allowed to use
388        /// network interfaces which have been marked as expensive.
389        ///
390        /// Returns: YES if the receiver is allowed to use an interface marked as expensive to
391        /// satisfy the request, NO otherwise.
392        #[unsafe(method(allowsExpensiveNetworkAccess))]
393        #[unsafe(method_family = none)]
394        pub unsafe fn allowsExpensiveNetworkAccess(&self) -> bool;
395
396        /// returns whether a connection created with this request is allowed to use
397        /// network interfaces which have been marked as constrained.
398        ///
399        /// Returns: YES if the receiver is allowed to use an interface marked as constrained to
400        /// satisfy the request, NO otherwise.
401        #[unsafe(method(allowsConstrainedNetworkAccess))]
402        #[unsafe(method_family = none)]
403        pub unsafe fn allowsConstrainedNetworkAccess(&self) -> bool;
404
405        /// returns whether we assume that server supports HTTP/3. Enables QUIC
406        /// racing without HTTP/3 service discovery.
407        ///
408        /// Returns: YES if server endpoint is known to support HTTP/3. Defaults to NO.
409        /// The default may be YES in a future OS update.
410        #[unsafe(method(assumesHTTP3Capable))]
411        #[unsafe(method_family = none)]
412        pub unsafe fn assumesHTTP3Capable(&self) -> bool;
413
414        /// Returns the NSURLRequestAttribution associated with this request.
415        ///
416        /// This will return NSURLRequestAttributionDeveloper for requests that
417        /// have not explicitly set an attribution.
418        ///
419        /// Returns: The NSURLRequestAttribution associated with this request.
420        #[unsafe(method(attribution))]
421        #[unsafe(method_family = none)]
422        pub unsafe fn attribution(&self) -> NSURLRequestAttribution;
423
424        /// sets whether a request is required to do DNSSEC validation during DNS lookup.
425        ///
426        /// YES, if the DNS lookup for this request should require DNSSEC validation,
427        /// No otherwise. Defaults to NO.
428        #[unsafe(method(requiresDNSSECValidation))]
429        #[unsafe(method_family = none)]
430        pub unsafe fn requiresDNSSECValidation(&self) -> bool;
431
432        /// Allows storing and usage of DNS answers, potentially beyond TTL expiry,
433        /// in a persistent per-process cache. This should only be set for hostnames whose resolutions
434        /// are not expected to change across networks.
435        ///
436        /// YES, if the DNS lookup for this request is allowed to use a persistent per-process cache,
437        /// NO otherwise. Defaults to NO.
438        #[unsafe(method(allowsPersistentDNS))]
439        #[unsafe(method_family = none)]
440        pub unsafe fn allowsPersistentDNS(&self) -> bool;
441
442        #[cfg(feature = "NSString")]
443        #[unsafe(method(cookiePartitionIdentifier))]
444        #[unsafe(method_family = none)]
445        pub unsafe fn cookiePartitionIdentifier(&self) -> Option<Retained<NSString>>;
446    );
447}
448
449/// Methods declared on superclass `NSObject`.
450impl NSURLRequest {
451    extern_methods!(
452        #[unsafe(method(init))]
453        #[unsafe(method_family = init)]
454        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
455
456        #[unsafe(method(new))]
457        #[unsafe(method_family = new)]
458        pub unsafe fn new() -> Retained<Self>;
459    );
460}
461
462extern_class!(
463    /// An NSMutableURLRequest object represents a mutable URL load
464    /// request in a manner independent of protocol and URL scheme.
465    ///
466    ///
467    /// This specialization of NSURLRequest is provided to aid
468    /// developers who may find it more convenient to mutate a single request
469    /// object for a series of URL loads instead of creating an immutable
470    /// NSURLRequest for each load. This programming model is supported by
471    /// the following contract stipulation between NSMutableURLRequest and
472    /// NSURLConnection: NSURLConnection makes a deep copy of each
473    /// NSMutableURLRequest object passed to one of its initializers.
474    /// <p>
475    /// NSMutableURLRequest is designed to be extended to support
476    /// protocol-specific data by adding categories to access a property
477    /// object provided in an interface targeted at protocol implementors.
478    /// <ul>
479    /// <li>
480    /// Protocol implementors should direct their attention to the
481    /// NSMutableURLRequestExtensibility category on
482    /// NSMutableURLRequest for more information on how to provide
483    /// extensions on NSMutableURLRequest to support protocol-specific
484    /// request information.
485    /// <li>
486    /// Clients of this API who wish to create NSMutableURLRequest
487    /// objects to load URL content should consult the protocol-specific
488    /// NSMutableURLRequest categories that are available. The
489    /// NSMutableHTTPURLRequest category on NSMutableURLRequest is an
490    /// example.
491    /// </ul>
492    ///
493    /// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmutableurlrequest?language=objc)
494    #[unsafe(super(NSURLRequest, NSObject))]
495    #[derive(Debug, PartialEq, Eq, Hash)]
496    pub struct NSMutableURLRequest;
497);
498
499#[cfg(feature = "NSObject")]
500unsafe impl NSCoding for NSMutableURLRequest {}
501
502#[cfg(feature = "NSObject")]
503unsafe impl NSCopying for NSMutableURLRequest {}
504
505#[cfg(feature = "NSObject")]
506unsafe impl CopyingHelper for NSMutableURLRequest {
507    type Result = NSURLRequest;
508}
509
510#[cfg(feature = "NSObject")]
511unsafe impl NSMutableCopying for NSMutableURLRequest {}
512
513#[cfg(feature = "NSObject")]
514unsafe impl MutableCopyingHelper for NSMutableURLRequest {
515    type Result = Self;
516}
517
518unsafe impl NSObjectProtocol for NSMutableURLRequest {}
519
520#[cfg(feature = "NSObject")]
521unsafe impl NSSecureCoding for NSMutableURLRequest {}
522
523impl NSMutableURLRequest {
524    extern_methods!(
525        #[cfg(feature = "NSURL")]
526        /// The URL of the receiver.
527        #[unsafe(method(URL))]
528        #[unsafe(method_family = none)]
529        pub unsafe fn URL(&self) -> Option<Retained<NSURL>>;
530
531        #[cfg(feature = "NSURL")]
532        /// Setter for [`URL`][Self::URL].
533        #[unsafe(method(setURL:))]
534        #[unsafe(method_family = none)]
535        pub unsafe fn setURL(&self, url: Option<&NSURL>);
536
537        /// The cache policy of the receiver.
538        #[unsafe(method(cachePolicy))]
539        #[unsafe(method_family = none)]
540        pub unsafe fn cachePolicy(&self) -> NSURLRequestCachePolicy;
541
542        /// Setter for [`cachePolicy`][Self::cachePolicy].
543        #[unsafe(method(setCachePolicy:))]
544        #[unsafe(method_family = none)]
545        pub unsafe fn setCachePolicy(&self, cache_policy: NSURLRequestCachePolicy);
546
547        #[cfg(feature = "NSDate")]
548        /// Sets the timeout interval of the receiver.
549        ///
550        /// The timeout interval specifies the limit on the idle
551        /// interval allotted to a request in the process of loading. The "idle
552        /// interval" is defined as the period of time that has passed since the
553        /// last instance of load activity occurred for a request that is in the
554        /// process of loading. Hence, when an instance of load activity occurs
555        /// (e.g. bytes are received from the network for a request), the idle
556        /// interval for a request is reset to 0. If the idle interval ever
557        /// becomes greater than or equal to the timeout interval, the request
558        /// is considered to have timed out. This timeout interval is measured
559        /// in seconds.
560        #[unsafe(method(timeoutInterval))]
561        #[unsafe(method_family = none)]
562        pub unsafe fn timeoutInterval(&self) -> NSTimeInterval;
563
564        #[cfg(feature = "NSDate")]
565        /// Setter for [`timeoutInterval`][Self::timeoutInterval].
566        #[unsafe(method(setTimeoutInterval:))]
567        #[unsafe(method_family = none)]
568        pub unsafe fn setTimeoutInterval(&self, timeout_interval: NSTimeInterval);
569
570        #[cfg(feature = "NSURL")]
571        /// Sets the main document URL
572        ///
573        /// The caller should pass the URL for an appropriate main
574        /// document, if known. For example, when loading a web page, the URL
575        /// of the main html document for the top-level frame should be
576        /// passed.  This main document is used to implement the cookie "only
577        /// from same domain as main document" policy, attributing this request
578        /// as a sub-resource of a user-specified URL, and possibly other things
579        /// in the future.
580        #[unsafe(method(mainDocumentURL))]
581        #[unsafe(method_family = none)]
582        pub unsafe fn mainDocumentURL(&self) -> Option<Retained<NSURL>>;
583
584        #[cfg(feature = "NSURL")]
585        /// Setter for [`mainDocumentURL`][Self::mainDocumentURL].
586        #[unsafe(method(setMainDocumentURL:))]
587        #[unsafe(method_family = none)]
588        pub unsafe fn setMainDocumentURL(&self, main_document_url: Option<&NSURL>);
589
590        /// Sets the NSURLRequestNetworkServiceType to associate with this request
591        ///
592        /// This method is used to provide the network layers with a hint as to the purpose
593        /// of the request.  Most clients should not need to use this method.
594        #[unsafe(method(networkServiceType))]
595        #[unsafe(method_family = none)]
596        pub unsafe fn networkServiceType(&self) -> NSURLRequestNetworkServiceType;
597
598        /// Setter for [`networkServiceType`][Self::networkServiceType].
599        #[unsafe(method(setNetworkServiceType:))]
600        #[unsafe(method_family = none)]
601        pub unsafe fn setNetworkServiceType(
602            &self,
603            network_service_type: NSURLRequestNetworkServiceType,
604        );
605
606        /// sets whether a connection created with this request is allowed to use
607        /// the built in cellular radios (if present).
608        ///
609        /// NO if the receiver should not be allowed to use the built in
610        /// cellular radios to satisfy the request, YES otherwise.  The default is YES.
611        #[unsafe(method(allowsCellularAccess))]
612        #[unsafe(method_family = none)]
613        pub unsafe fn allowsCellularAccess(&self) -> bool;
614
615        /// Setter for [`allowsCellularAccess`][Self::allowsCellularAccess].
616        #[unsafe(method(setAllowsCellularAccess:))]
617        #[unsafe(method_family = none)]
618        pub unsafe fn setAllowsCellularAccess(&self, allows_cellular_access: bool);
619
620        /// sets whether a connection created with this request is allowed to use
621        /// network interfaces which have been marked as expensive.
622        ///
623        /// NO if the receiver should not be allowed to use an interface marked as expensive to
624        /// satisfy the request, YES otherwise.
625        #[unsafe(method(allowsExpensiveNetworkAccess))]
626        #[unsafe(method_family = none)]
627        pub unsafe fn allowsExpensiveNetworkAccess(&self) -> bool;
628
629        /// Setter for [`allowsExpensiveNetworkAccess`][Self::allowsExpensiveNetworkAccess].
630        #[unsafe(method(setAllowsExpensiveNetworkAccess:))]
631        #[unsafe(method_family = none)]
632        pub unsafe fn setAllowsExpensiveNetworkAccess(&self, allows_expensive_network_access: bool);
633
634        /// sets whether a connection created with this request is allowed to use
635        /// network interfaces which have been marked as constrained.
636        ///
637        /// NO if the receiver should not be allowed to use an interface marked as constrained to
638        /// satisfy the request, YES otherwise.
639        #[unsafe(method(allowsConstrainedNetworkAccess))]
640        #[unsafe(method_family = none)]
641        pub unsafe fn allowsConstrainedNetworkAccess(&self) -> bool;
642
643        /// Setter for [`allowsConstrainedNetworkAccess`][Self::allowsConstrainedNetworkAccess].
644        #[unsafe(method(setAllowsConstrainedNetworkAccess:))]
645        #[unsafe(method_family = none)]
646        pub unsafe fn setAllowsConstrainedNetworkAccess(
647            &self,
648            allows_constrained_network_access: bool,
649        );
650
651        /// returns whether we assume that server supports HTTP/3. Enables QUIC
652        /// racing without HTTP/3 service discovery.
653        ///
654        /// Returns: YES if server endpoint is known to support HTTP/3. Defaults to NO.
655        /// The default may be YES in a future OS update.
656        #[unsafe(method(assumesHTTP3Capable))]
657        #[unsafe(method_family = none)]
658        pub unsafe fn assumesHTTP3Capable(&self) -> bool;
659
660        /// Setter for [`assumesHTTP3Capable`][Self::assumesHTTP3Capable].
661        #[unsafe(method(setAssumesHTTP3Capable:))]
662        #[unsafe(method_family = none)]
663        pub unsafe fn setAssumesHTTP3Capable(&self, assumes_http3_capable: bool);
664
665        /// Sets the NSURLRequestAttribution to associate with this request.
666        ///
667        /// Set to NSURLRequestAttributionUser if the URL was specified by the
668        /// user. Defaults to NSURLRequestAttributionDeveloper.
669        #[unsafe(method(attribution))]
670        #[unsafe(method_family = none)]
671        pub unsafe fn attribution(&self) -> NSURLRequestAttribution;
672
673        /// Setter for [`attribution`][Self::attribution].
674        #[unsafe(method(setAttribution:))]
675        #[unsafe(method_family = none)]
676        pub unsafe fn setAttribution(&self, attribution: NSURLRequestAttribution);
677
678        /// sets whether a request is required to do DNSSEC validation during DNS lookup.
679        ///
680        /// YES, if the DNS lookup for this request should require DNSSEC validation,
681        /// No otherwise. Defaults to NO.
682        #[unsafe(method(requiresDNSSECValidation))]
683        #[unsafe(method_family = none)]
684        pub unsafe fn requiresDNSSECValidation(&self) -> bool;
685
686        /// Setter for [`requiresDNSSECValidation`][Self::requiresDNSSECValidation].
687        #[unsafe(method(setRequiresDNSSECValidation:))]
688        #[unsafe(method_family = none)]
689        pub unsafe fn setRequiresDNSSECValidation(&self, requires_dnssec_validation: bool);
690
691        /// Allows storing and usage of DNS answers, potentially beyond TTL expiry,
692        /// in a persistent per-process cache. This should only be set for hostnames whose resolutions
693        /// are not expected to change across networks.
694        ///
695        /// YES, if the DNS lookup for this request is allowed to use a persistent per-process cache,
696        /// NO otherwise. Defaults to NO.
697        #[unsafe(method(allowsPersistentDNS))]
698        #[unsafe(method_family = none)]
699        pub unsafe fn allowsPersistentDNS(&self) -> bool;
700
701        /// Setter for [`allowsPersistentDNS`][Self::allowsPersistentDNS].
702        #[unsafe(method(setAllowsPersistentDNS:))]
703        #[unsafe(method_family = none)]
704        pub unsafe fn setAllowsPersistentDNS(&self, allows_persistent_dns: bool);
705
706        #[cfg(feature = "NSString")]
707        #[unsafe(method(cookiePartitionIdentifier))]
708        #[unsafe(method_family = none)]
709        pub unsafe fn cookiePartitionIdentifier(&self) -> Option<Retained<NSString>>;
710
711        #[cfg(feature = "NSString")]
712        /// Setter for [`cookiePartitionIdentifier`][Self::cookiePartitionIdentifier].
713        #[unsafe(method(setCookiePartitionIdentifier:))]
714        #[unsafe(method_family = none)]
715        pub unsafe fn setCookiePartitionIdentifier(
716            &self,
717            cookie_partition_identifier: Option<&NSString>,
718        );
719    );
720}
721
722/// Methods declared on superclass `NSURLRequest`.
723impl NSMutableURLRequest {
724    extern_methods!(
725        #[cfg(feature = "NSURL")]
726        /// Allocates and initializes an NSURLRequest with the given
727        /// URL.
728        ///
729        /// Default values are used for cache policy
730        /// (NSURLRequestUseProtocolCachePolicy) and timeout interval (60
731        /// seconds).
732        ///
733        /// Parameter `URL`: The URL for the request.
734        ///
735        /// Returns: A newly-created and autoreleased NSURLRequest instance.
736        #[unsafe(method(requestWithURL:))]
737        #[unsafe(method_family = none)]
738        pub unsafe fn requestWithURL(url: &NSURL) -> Retained<Self>;
739
740        #[cfg(all(feature = "NSDate", feature = "NSURL"))]
741        /// Allocates and initializes a NSURLRequest with the given
742        /// URL and cache policy.
743        ///
744        /// Parameter `URL`: The URL for the request.
745        ///
746        /// Parameter `cachePolicy`: The cache policy for the request.
747        ///
748        /// Parameter `timeoutInterval`: The timeout interval for the request. See the
749        /// commentary for the
750        /// <tt>
751        /// timeoutInterval
752        /// </tt>
753        /// for more information on
754        /// timeout intervals.
755        ///
756        /// Returns: A newly-created and autoreleased NSURLRequest instance.
757        #[unsafe(method(requestWithURL:cachePolicy:timeoutInterval:))]
758        #[unsafe(method_family = none)]
759        pub unsafe fn requestWithURL_cachePolicy_timeoutInterval(
760            url: &NSURL,
761            cache_policy: NSURLRequestCachePolicy,
762            timeout_interval: NSTimeInterval,
763        ) -> Retained<Self>;
764
765        #[cfg(feature = "NSURL")]
766        /// Initializes an NSURLRequest with the given URL.
767        ///
768        /// Default values are used for cache policy
769        /// (NSURLRequestUseProtocolCachePolicy) and timeout interval (60
770        /// seconds).
771        ///
772        /// Parameter `URL`: The URL for the request.
773        ///
774        /// Returns: An initialized NSURLRequest.
775        #[unsafe(method(initWithURL:))]
776        #[unsafe(method_family = init)]
777        pub unsafe fn initWithURL(this: Allocated<Self>, url: &NSURL) -> Retained<Self>;
778
779        #[cfg(all(feature = "NSDate", feature = "NSURL"))]
780        /// Initializes an NSURLRequest with the given URL and
781        /// cache policy.
782        ///
783        /// This is the designated initializer for the
784        /// NSURLRequest class.
785        ///
786        /// Parameter `URL`: The URL for the request.
787        ///
788        /// Parameter `cachePolicy`: The cache policy for the request.
789        ///
790        /// Parameter `timeoutInterval`: The timeout interval for the request. See the
791        /// commentary for the
792        /// <tt>
793        /// timeoutInterval
794        /// </tt>
795        /// for more information on
796        /// timeout intervals.
797        ///
798        /// Returns: An initialized NSURLRequest.
799        #[unsafe(method(initWithURL:cachePolicy:timeoutInterval:))]
800        #[unsafe(method_family = init)]
801        pub unsafe fn initWithURL_cachePolicy_timeoutInterval(
802            this: Allocated<Self>,
803            url: &NSURL,
804            cache_policy: NSURLRequestCachePolicy,
805            timeout_interval: NSTimeInterval,
806        ) -> Retained<Self>;
807    );
808}
809
810/// Methods declared on superclass `NSObject`.
811impl NSMutableURLRequest {
812    extern_methods!(
813        #[unsafe(method(init))]
814        #[unsafe(method_family = init)]
815        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
816
817        #[unsafe(method(new))]
818        #[unsafe(method_family = new)]
819        pub unsafe fn new() -> Retained<Self>;
820    );
821}
822
823/// NSHTTPURLRequest.
824/// The NSHTTPURLRequest on NSURLRequest provides methods for accessing
825/// information specific to HTTP protocol requests.
826impl NSURLRequest {
827    extern_methods!(
828        #[cfg(feature = "NSString")]
829        /// Returns the HTTP request method of the receiver.
830        ///
831        /// Returns: the HTTP request method of the receiver.
832        #[unsafe(method(HTTPMethod))]
833        #[unsafe(method_family = none)]
834        pub unsafe fn HTTPMethod(&self) -> Option<Retained<NSString>>;
835
836        #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
837        /// Returns a dictionary containing all the HTTP header fields
838        /// of the receiver.
839        ///
840        /// Returns: a dictionary containing all the HTTP header fields of the
841        /// receiver.
842        #[unsafe(method(allHTTPHeaderFields))]
843        #[unsafe(method_family = none)]
844        pub unsafe fn allHTTPHeaderFields(
845            &self,
846        ) -> Option<Retained<NSDictionary<NSString, NSString>>>;
847
848        #[cfg(feature = "NSString")]
849        /// Returns the value which corresponds to the given header
850        /// field. Note that, in keeping with the HTTP RFC, HTTP header field
851        /// names are case-insensitive.
852        ///
853        /// Parameter `field`: the header field name to use for the lookup
854        /// (case-insensitive).
855        ///
856        /// Returns: the value associated with the given header field, or nil if
857        /// there is no value associated with the given header field.
858        #[unsafe(method(valueForHTTPHeaderField:))]
859        #[unsafe(method_family = none)]
860        pub unsafe fn valueForHTTPHeaderField(
861            &self,
862            field: &NSString,
863        ) -> Option<Retained<NSString>>;
864
865        #[cfg(feature = "NSData")]
866        /// Returns the request body data of the receiver.
867        ///
868        /// This data is sent as the message body of the request, as
869        /// in done in an HTTP POST request.
870        ///
871        /// Returns: The request body data of the receiver.
872        #[unsafe(method(HTTPBody))]
873        #[unsafe(method_family = none)]
874        pub unsafe fn HTTPBody(&self) -> Option<Retained<NSData>>;
875
876        #[cfg(feature = "NSStream")]
877        /// Returns the request body stream of the receiver
878        /// if any has been set
879        ///
880        /// The stream is returned for examination only; it is
881        /// not safe for the caller to manipulate the stream in any way.  Also
882        /// note that the HTTPBodyStream and HTTPBody are mutually exclusive - only
883        /// one can be set on a given request.  Also note that the body stream is
884        /// preserved across copies, but is LOST when the request is coded via the
885        /// NSCoding protocol
886        ///
887        /// Returns: The request body stream of the receiver.
888        #[unsafe(method(HTTPBodyStream))]
889        #[unsafe(method_family = none)]
890        pub unsafe fn HTTPBodyStream(&self) -> Option<Retained<NSInputStream>>;
891
892        /// Determine whether default cookie handling will happen for
893        /// this request.
894        ///
895        /// NOTE: This value is not used prior to 10.3
896        ///
897        /// Returns: YES if cookies will be sent with and set for this request;
898        /// otherwise NO.
899        #[unsafe(method(HTTPShouldHandleCookies))]
900        #[unsafe(method_family = none)]
901        pub unsafe fn HTTPShouldHandleCookies(&self) -> bool;
902
903        /// Reports whether the receiver is not expected to wait for the
904        /// previous response before transmitting.
905        ///
906        /// Returns: YES if the receiver should transmit before the previous response
907        /// is received.  NO if the receiver should wait for the previous response
908        /// before transmitting.
909        #[unsafe(method(HTTPShouldUsePipelining))]
910        #[unsafe(method_family = none)]
911        pub unsafe fn HTTPShouldUsePipelining(&self) -> bool;
912    );
913}
914
915/// NSMutableHTTPURLRequest.
916/// The NSMutableHTTPURLRequest on NSMutableURLRequest provides methods
917/// for configuring information specific to HTTP protocol requests.
918impl NSMutableURLRequest {
919    extern_methods!(
920        #[cfg(feature = "NSString")]
921        /// Sets the HTTP request method of the receiver.
922        #[unsafe(method(HTTPMethod))]
923        #[unsafe(method_family = none)]
924        pub unsafe fn HTTPMethod(&self) -> Retained<NSString>;
925
926        #[cfg(feature = "NSString")]
927        /// Setter for [`HTTPMethod`][Self::HTTPMethod].
928        #[unsafe(method(setHTTPMethod:))]
929        #[unsafe(method_family = none)]
930        pub unsafe fn setHTTPMethod(&self, http_method: &NSString);
931
932        #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
933        /// Sets the HTTP header fields of the receiver to the given
934        /// dictionary.
935        ///
936        /// This method replaces all header fields that may have
937        /// existed before this method call.
938        /// <p>
939        /// Since HTTP header fields must be string values, each object and
940        /// key in the dictionary passed to this method must answer YES when
941        /// sent an
942        /// <tt>
943        /// -isKindOfClass:[NSString class]
944        /// </tt>
945        /// message. If either
946        /// the key or value for a key-value pair answers NO when sent this
947        /// message, the key-value pair is skipped.
948        #[unsafe(method(allHTTPHeaderFields))]
949        #[unsafe(method_family = none)]
950        pub unsafe fn allHTTPHeaderFields(
951            &self,
952        ) -> Option<Retained<NSDictionary<NSString, NSString>>>;
953
954        #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
955        /// Setter for [`allHTTPHeaderFields`][Self::allHTTPHeaderFields].
956        #[unsafe(method(setAllHTTPHeaderFields:))]
957        #[unsafe(method_family = none)]
958        pub unsafe fn setAllHTTPHeaderFields(
959            &self,
960            all_http_header_fields: Option<&NSDictionary<NSString, NSString>>,
961        );
962
963        #[cfg(feature = "NSString")]
964        /// Sets the value of the given HTTP header field.
965        ///
966        /// If a value was previously set for the given header
967        /// field, that value is replaced with the given value. Note that, in
968        /// keeping with the HTTP RFC, HTTP header field names are
969        /// case-insensitive.
970        ///
971        /// Parameter `value`: the header field value.
972        ///
973        /// Parameter `field`: the header field name (case-insensitive).
974        #[unsafe(method(setValue:forHTTPHeaderField:))]
975        #[unsafe(method_family = none)]
976        pub unsafe fn setValue_forHTTPHeaderField(
977            &self,
978            value: Option<&NSString>,
979            field: &NSString,
980        );
981
982        #[cfg(feature = "NSString")]
983        /// Adds an HTTP header field in the current header
984        /// dictionary.
985        ///
986        /// This method provides a way to add values to header
987        /// fields incrementally. If a value was previously set for the given
988        /// header field, the given value is appended to the previously-existing
989        /// value. The appropriate field delimiter, a comma in the case of HTTP,
990        /// is added by the implementation, and should not be added to the given
991        /// value by the caller. Note that, in keeping with the HTTP RFC, HTTP
992        /// header field names are case-insensitive.
993        ///
994        /// Parameter `value`: the header field value.
995        ///
996        /// Parameter `field`: the header field name (case-insensitive).
997        #[unsafe(method(addValue:forHTTPHeaderField:))]
998        #[unsafe(method_family = none)]
999        pub unsafe fn addValue_forHTTPHeaderField(&self, value: &NSString, field: &NSString);
1000
1001        #[cfg(feature = "NSData")]
1002        /// Sets the request body data of the receiver.
1003        ///
1004        /// This data is sent as the message body of the request, as
1005        /// in done in an HTTP POST request.
1006        #[unsafe(method(HTTPBody))]
1007        #[unsafe(method_family = none)]
1008        pub unsafe fn HTTPBody(&self) -> Option<Retained<NSData>>;
1009
1010        #[cfg(feature = "NSData")]
1011        /// Setter for [`HTTPBody`][Self::HTTPBody].
1012        #[unsafe(method(setHTTPBody:))]
1013        #[unsafe(method_family = none)]
1014        pub unsafe fn setHTTPBody(&self, http_body: Option<&NSData>);
1015
1016        #[cfg(feature = "NSStream")]
1017        /// Sets the request body to be the contents of the given stream.
1018        ///
1019        /// The provided stream should be unopened; the request will take
1020        /// over the stream's delegate.  The entire stream's contents will be
1021        /// transmitted as the HTTP body of the request.  Note that the body stream
1022        /// and the body data (set by setHTTPBody:, above) are mutually exclusive
1023        /// - setting one will clear the other.
1024        #[unsafe(method(HTTPBodyStream))]
1025        #[unsafe(method_family = none)]
1026        pub unsafe fn HTTPBodyStream(&self) -> Option<Retained<NSInputStream>>;
1027
1028        #[cfg(feature = "NSStream")]
1029        /// Setter for [`HTTPBodyStream`][Self::HTTPBodyStream].
1030        #[unsafe(method(setHTTPBodyStream:))]
1031        #[unsafe(method_family = none)]
1032        pub unsafe fn setHTTPBodyStream(&self, http_body_stream: Option<&NSInputStream>);
1033
1034        /// Decide whether default cookie handling will happen for
1035        /// this request (YES if cookies should be sent with and set for this request;
1036        /// otherwise NO).
1037        ///
1038        /// The default is YES - in other words, cookies are sent from and
1039        /// stored to the cookie manager by default.
1040        /// NOTE: In releases prior to 10.3, this value is ignored
1041        #[unsafe(method(HTTPShouldHandleCookies))]
1042        #[unsafe(method_family = none)]
1043        pub unsafe fn HTTPShouldHandleCookies(&self) -> bool;
1044
1045        /// Setter for [`HTTPShouldHandleCookies`][Self::HTTPShouldHandleCookies].
1046        #[unsafe(method(setHTTPShouldHandleCookies:))]
1047        #[unsafe(method_family = none)]
1048        pub unsafe fn setHTTPShouldHandleCookies(&self, http_should_handle_cookies: bool);
1049
1050        /// Sets whether the request should not wait for the previous response
1051        /// before transmitting (YES if the receiver should transmit before the previous response is
1052        /// received.  NO to wait for the previous response before transmitting)
1053        ///
1054        /// Calling this method with a YES value does not guarantee HTTP
1055        /// pipelining behavior.  This method may have no effect if an HTTP proxy is
1056        /// configured, or if the HTTP request uses an unsafe request method (e.g., POST
1057        /// requests will not pipeline).  Pipelining behavior also may not begin until
1058        /// the second request on a given TCP connection.  There may be other situations
1059        /// where pipelining does not occur even though YES was set.
1060        /// HTTP 1.1 allows the client to send multiple requests to the server without
1061        /// waiting for a response.  Though HTTP 1.1 requires support for pipelining,
1062        /// some servers report themselves as being HTTP 1.1 but do not support
1063        /// pipelining (disconnecting, sending resources misordered, omitting part of
1064        /// a resource, etc.).
1065        #[unsafe(method(HTTPShouldUsePipelining))]
1066        #[unsafe(method_family = none)]
1067        pub unsafe fn HTTPShouldUsePipelining(&self) -> bool;
1068
1069        /// Setter for [`HTTPShouldUsePipelining`][Self::HTTPShouldUsePipelining].
1070        #[unsafe(method(setHTTPShouldUsePipelining:))]
1071        #[unsafe(method_family = none)]
1072        pub unsafe fn setHTTPShouldUsePipelining(&self, http_should_use_pipelining: bool);
1073    );
1074}