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