@@ -241,11 +241,29 @@ public class NSURLRequest : NSObject, NSSecureCoding, NSCopying, NSMutableCopyin
241
241
*/
242
242
/*@NSCopying */public private( set) var URL : NSURL ?
243
243
244
+ /// The cache policy of the receiver.
244
245
public private( set) var cachePolicy : NSURLRequestCachePolicy = . UseProtocolCachePolicy
246
+
247
+ /// The timeout interval.
248
+ ///
249
+ /// The timeout interval specifies the limit on the idle
250
+ /// interval allotted to a request in the process of loading. The *idle
251
+ /// interval* is defined as the period of time that has passed since the
252
+ /// last instance of load activity occurred for a request that is in the
253
+ /// process of loading. Hence, when an instance of load activity occurs
254
+ /// (e.g. bytes are received from the network for a request), the idle
255
+ /// interval for a request is reset to 0. If the idle interval ever
256
+ /// becomes greater than or equal to the timeout interval, the request
257
+ /// is considered to have timed out. This timeout interval is measured
258
+ /// in seconds.
245
259
public private( set) var timeoutInterval : NSTimeInterval = 60
260
+
261
+ /// The `NSURLRequestNetworkServiceType` associated with this request.
262
+ ///
263
+ /// This method is used to provide the network layers with a hint as to the
264
+ /// purpose of the request. Most clients should not need to use this method.
246
265
public private( set) var networkServiceType : NSURLRequestNetworkServiceType = . NetworkServiceTypeDefault
247
- public private( set) var allowsCellularAccess : Bool = true
248
-
266
+
249
267
/*!
250
268
@method mainDocumentURL
251
269
@abstract The main document URL associated with this load.
@@ -272,6 +290,23 @@ public class NSURLRequest : NSObject, NSSecureCoding, NSCopying, NSMutableCopyin
272
290
*/
273
291
public private( set) var allHTTPHeaderFields : [ String : String ] ?
274
292
293
+ /// HTTP body data.
294
+ ///
295
+ /// This is sent as the message body, as in an HTTP POST request.
296
+ public private( set) var HTTPBody : NSData ? {
297
+ didSet { precondition ( HTTPBody == nil || HTTPBodyStream == nil , " Must not set both HTTPBody and HTTPBodyStream. " ) }
298
+ }
299
+
300
+ /// HTTP body stream.
301
+ ///
302
+ /// - Returns: `nil` if the body stream has not been set. The returned stream is for examination only -- it is not safe to manipulate the stream in any way.
303
+ ///
304
+ /// - Note: A request can have an HTTP body or an HTTP body stream, only one may be set for a request.
305
+ /// - Note: A HTTP body stream is preserved when copying an NSURLRequest object, but is lost when a request is archived using the NSCoding protocol.
306
+ public private( set) var HTTPBodyStream : NSInputStream ? {
307
+ didSet { precondition ( HTTPBody == nil || HTTPBodyStream == nil , " Must not set both HTTPBody and HTTPBodyStream. " ) }
308
+ }
309
+
275
310
/*!
276
311
@method valueForHTTPHeaderField:
277
312
@abstract Returns the value which corresponds to the given header
@@ -318,9 +353,6 @@ public class NSURLRequest : NSObject, NSSecureCoding, NSCopying, NSMutableCopyin
318
353
</ul>
319
354
*/
320
355
public class NSMutableURLRequest : NSURLRequest {
321
-
322
- private var _HTTPMethod : String ? = " GET "
323
-
324
356
public required init ? ( coder aDecoder: NSCoder ) {
325
357
super. init ( )
326
358
}
@@ -364,21 +396,55 @@ public class NSMutableURLRequest : NSURLRequest {
364
396
set { super. HTTPMethod = newValue }
365
397
}
366
398
399
+ /// The cache policy of the receiver.
367
400
public override var cachePolicy : NSURLRequestCachePolicy {
368
401
get { return super. cachePolicy }
369
402
set { super. cachePolicy = newValue }
370
403
}
404
+
405
+ /// The timeout interval.
406
+ ///
407
+ /// The timeout interval specifies the limit on the idle
408
+ /// interval allotted to a request in the process of loading. The *idle
409
+ /// interval* is defined as the period of time that has passed since the
410
+ /// last instance of load activity occurred for a request that is in the
411
+ /// process of loading. Hence, when an instance of load activity occurs
412
+ /// (e.g. bytes are received from the network for a request), the idle
413
+ /// interval for a request is reset to 0. If the idle interval ever
414
+ /// becomes greater than or equal to the timeout interval, the request
415
+ /// is considered to have timed out. This timeout interval is measured
416
+ /// in seconds.
371
417
public override var timeoutInterval : NSTimeInterval {
372
418
get { return super. timeoutInterval }
373
419
set { super. timeoutInterval = newValue }
374
420
}
421
+
422
+ /// The `NSURLRequestNetworkServiceType` associated with this request.
423
+ ///
424
+ /// This method is used to provide the network layers with a hint as to the
425
+ /// purpose of the request. Most clients should not need to use this method.
375
426
public override var networkServiceType : NSURLRequestNetworkServiceType {
376
427
get { return super. networkServiceType }
377
428
set { super. networkServiceType = newValue }
378
429
}
379
- public override var allowsCellularAccess : Bool {
380
- get { return super. allowsCellularAccess }
381
- set { super. allowsCellularAccess = newValue }
430
+
431
+ /// HTTP body data.
432
+ ///
433
+ /// This is sent as the message body, as in an HTTP POST request.
434
+ public override var HTTPBody : NSData ? {
435
+ get { return super. HTTPBody }
436
+ set { super. HTTPBody = newValue. map ( { $0. copy ( ) as! NSData } ) }
437
+ }
438
+
439
+ /// HTTP body stream.
440
+ ///
441
+ /// - Returns: `nil` if the body stream has not been set. The returned stream is for examination only -- it is not safe to manipulate the stream in any way.
442
+ ///
443
+ /// - Note: A request can have an HTTP body or an HTTP body stream, only one may be set for a request.
444
+ /// - Note: A HTTP body stream is preserved when copying an NSURLRequest object, but is lost when a request is archived using the NSCoding protocol.
445
+ public override var HTTPBodyStream : NSInputStream ? {
446
+ get { return super. HTTPBodyStream }
447
+ set { super. HTTPBodyStream = newValue }
382
448
}
383
449
384
450
/*!
0 commit comments