@@ -179,9 +179,10 @@ public class NSURLRequest : NSObject, NSSecureCoding, NSCopying, NSMutableCopyin
179
179
cachePolicy = other. cachePolicy
180
180
timeoutInterval = other. timeoutInterval
181
181
networkServiceType = other. networkServiceType
182
- allowsCellularAccess = other. allowsCellularAccess
183
182
HTTPMethod = other. HTTPMethod
184
183
allHTTPHeaderFields = other. allHTTPHeaderFields
184
+ HTTPBody = other. HTTPBody
185
+ HTTPBodyStream = other. HTTPBodyStream
185
186
}
186
187
187
188
public override func mutableCopy( ) -> AnyObject {
@@ -255,11 +256,29 @@ public class NSURLRequest : NSObject, NSSecureCoding, NSCopying, NSMutableCopyin
255
256
*/
256
257
/*@NSCopying */public private( set) var URL : NSURL ?
257
258
259
+ /// The cache policy of the receiver.
258
260
public private( set) var cachePolicy : NSURLRequestCachePolicy = . UseProtocolCachePolicy
261
+
262
+ /// The timeout interval.
263
+ ///
264
+ /// The timeout interval specifies the limit on the idle
265
+ /// interval allotted to a request in the process of loading. The *idle
266
+ /// interval* is defined as the period of time that has passed since the
267
+ /// last instance of load activity occurred for a request that is in the
268
+ /// process of loading. Hence, when an instance of load activity occurs
269
+ /// (e.g. bytes are received from the network for a request), the idle
270
+ /// interval for a request is reset to 0. If the idle interval ever
271
+ /// becomes greater than or equal to the timeout interval, the request
272
+ /// is considered to have timed out. This timeout interval is measured
273
+ /// in seconds.
259
274
public private( set) var timeoutInterval : NSTimeInterval = 60
275
+
276
+ /// The `NSURLRequestNetworkServiceType` associated with this request.
277
+ ///
278
+ /// This method is used to provide the network layers with a hint as to the
279
+ /// purpose of the request. Most clients should not need to use this method.
260
280
public private( set) var networkServiceType : NSURLRequestNetworkServiceType = . NetworkServiceTypeDefault
261
- public private( set) var allowsCellularAccess : Bool = true
262
-
281
+
263
282
/*!
264
283
@method mainDocumentURL
265
284
@abstract The main document URL associated with this load.
@@ -286,6 +305,23 @@ public class NSURLRequest : NSObject, NSSecureCoding, NSCopying, NSMutableCopyin
286
305
*/
287
306
public private( set) var allHTTPHeaderFields : [ String : String ] ?
288
307
308
+ /// HTTP body data.
309
+ ///
310
+ /// This is sent as the message body, as in an HTTP POST request.
311
+ public private( set) var HTTPBody : NSData ? {
312
+ didSet { precondition ( HTTPBody == nil || HTTPBodyStream == nil , " Must not set both HTTPBody and HTTPBodyStream. " ) }
313
+ }
314
+
315
+ /// HTTP body stream.
316
+ ///
317
+ /// - 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.
318
+ ///
319
+ /// - Note: A request can have an HTTP body or an HTTP body stream, only one may be set for a request.
320
+ /// - Note: A HTTP body stream is preserved when copying an NSURLRequest object, but is lost when a request is archived using the NSCoding protocol.
321
+ public private( set) var HTTPBodyStream : NSInputStream ? {
322
+ didSet { precondition ( HTTPBody == nil || HTTPBodyStream == nil , " Must not set both HTTPBody and HTTPBodyStream. " ) }
323
+ }
324
+
289
325
/*!
290
326
@method valueForHTTPHeaderField:
291
327
@abstract Returns the value which corresponds to the given header
@@ -332,9 +368,6 @@ public class NSURLRequest : NSObject, NSSecureCoding, NSCopying, NSMutableCopyin
332
368
</ul>
333
369
*/
334
370
public class NSMutableURLRequest : NSURLRequest {
335
-
336
- private var _HTTPMethod : String ? = " GET "
337
-
338
371
public required init ? ( coder aDecoder: NSCoder ) {
339
372
super. init ( )
340
373
}
@@ -378,21 +411,55 @@ public class NSMutableURLRequest : NSURLRequest {
378
411
set { super. HTTPMethod = newValue }
379
412
}
380
413
414
+ /// The cache policy of the receiver.
381
415
public override var cachePolicy : NSURLRequestCachePolicy {
382
416
get { return super. cachePolicy }
383
417
set { super. cachePolicy = newValue }
384
418
}
419
+
420
+ /// The timeout interval.
421
+ ///
422
+ /// The timeout interval specifies the limit on the idle
423
+ /// interval allotted to a request in the process of loading. The *idle
424
+ /// interval* is defined as the period of time that has passed since the
425
+ /// last instance of load activity occurred for a request that is in the
426
+ /// process of loading. Hence, when an instance of load activity occurs
427
+ /// (e.g. bytes are received from the network for a request), the idle
428
+ /// interval for a request is reset to 0. If the idle interval ever
429
+ /// becomes greater than or equal to the timeout interval, the request
430
+ /// is considered to have timed out. This timeout interval is measured
431
+ /// in seconds.
385
432
public override var timeoutInterval : NSTimeInterval {
386
433
get { return super. timeoutInterval }
387
434
set { super. timeoutInterval = newValue }
388
435
}
436
+
437
+ /// The `NSURLRequestNetworkServiceType` associated with this request.
438
+ ///
439
+ /// This method is used to provide the network layers with a hint as to the
440
+ /// purpose of the request. Most clients should not need to use this method.
389
441
public override var networkServiceType : NSURLRequestNetworkServiceType {
390
442
get { return super. networkServiceType }
391
443
set { super. networkServiceType = newValue }
392
444
}
393
- public override var allowsCellularAccess : Bool {
394
- get { return super. allowsCellularAccess }
395
- set { super. allowsCellularAccess = newValue }
445
+
446
+ /// HTTP body data.
447
+ ///
448
+ /// This is sent as the message body, as in an HTTP POST request.
449
+ public override var HTTPBody : NSData ? {
450
+ get { return super. HTTPBody }
451
+ set { super. HTTPBody = newValue. map ( { $0. copy ( ) as! NSData } ) }
452
+ }
453
+
454
+ /// HTTP body stream.
455
+ ///
456
+ /// - 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.
457
+ ///
458
+ /// - Note: A request can have an HTTP body or an HTTP body stream, only one may be set for a request.
459
+ /// - Note: A HTTP body stream is preserved when copying an NSURLRequest object, but is lost when a request is archived using the NSCoding protocol.
460
+ public override var HTTPBodyStream : NSInputStream ? {
461
+ get { return super. HTTPBodyStream }
462
+ set { super. HTTPBodyStream = newValue }
396
463
}
397
464
398
465
/*!
0 commit comments