iOS-NSURLRequest的理解与应用

NSURLRequest官方文档

@interface NSURLRequest : NSObject <NSSecureCoding, NSCopying, NSMutableCopying>
{
    @private
    NSURLRequestInternal *_internal;
}

+ (instancetype)requestWithURL:(NSURL *)URL;

#if FOUNDATION_SWIFT_SDK_EPOCH_AT_LEAST(8)
@property (class, readonly) BOOL supportsSecureCoding;
#endif

+ (instancetype)requestWithURL:(NSURL *)URL cachePolicy:(NSURLRequestCachePolicy)cachePolicy timeoutInterval:(NSTimeInterval)timeoutInterval;

- (instancetype)initWithURL:(NSURL *)URL;

- (instancetype)initWithURL:(NSURL *)URL cachePolicy:(NSURLRequestCachePolicy)cachePolicy timeoutInterval:(NSTimeInterval)timeoutInterval NS_DESIGNATED_INITIALIZER;

@property (nullable, readonly, copy) NSURL *URL;

@property (readonly) NSURLRequestCachePolicy cachePolicy;

@property (readonly) NSTimeInterval timeoutInterval;

@property (nullable, readonly, copy) NSURL *mainDocumentURL;

@property (readonly) NSURLRequestNetworkServiceType networkServiceType NS_AVAILABLE(10_7, 4_0);

@property (readonly) BOOL allowsCellularAccess  NS_AVAILABLE(10_8, 6_0);

@end

@interface NSMutableURLRequest : NSURLRequest

@property (nullable, copy) NSURL *URL;

@property NSURLRequestCachePolicy cachePolicy;

@property NSTimeInterval timeoutInterval;

@property (nullable, copy) NSURL *mainDocumentURL;

@property NSURLRequestNetworkServiceType networkServiceType NS_AVAILABLE(10_7, 4_0);

@property BOOL allowsCellularAccess NS_AVAILABLE(10_8, 6_0);

@end

@interface NSURLRequest (NSHTTPURLRequest) 

@property (nullable, readonly, copy) NSString *HTTPMethod;

@property (nullable, readonly, copy) NSDictionary<NSString *, NSString *> *allHTTPHeaderFields;

- (nullable NSString *)valueForHTTPHeaderField:(NSString *)field;

@property (nullable, readonly, copy) NSData *HTTPBody;

@property (nullable, readonly, retain) NSInputStream *HTTPBodyStream;

@property (readonly) BOOL HTTPShouldHandleCookies;

@property (readonly) BOOL HTTPShouldUsePipelining NS_AVAILABLE(10_7, 4_0);

@end

@interface NSMutableURLRequest (NSMutableHTTPURLRequest) 

@property (copy) NSString *HTTPMethod;

@property (nullable, copy) NSDictionary<NSString *, NSString *> *allHTTPHeaderFields;

- (void)setValue:(nullable NSString *)value forHTTPHeaderField:(NSString *)field;

- (void)addValue:(NSString *)value forHTTPHeaderField:(NSString *)field;

@property (nullable, copy) NSData *HTTPBody;

@property (nullable, retain) NSInputStream *HTTPBodyStream;

@property BOOL HTTPShouldHandleCookies;

@property BOOL HTTPShouldUsePipelining NS_AVAILABLE(10_7, 4_0);

@end
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值