old mode 100755
new mode 100644
|  |  |  | 
|---|
|  |  |  | // AFURLRequestSerialization.h | 
|---|
|  |  |  | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) | 
|---|
|  |  |  | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) | 
|---|
|  |  |  | // | 
|---|
|  |  |  | // Permission is hereby granted, free of charge, to any person obtaining a copy | 
|---|
|  |  |  | // of this software and associated documentation files (the "Software"), to deal | 
|---|
|  |  |  | 
|---|
|  |  |  | // THE SOFTWARE. | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #import <Foundation/Foundation.h> | 
|---|
|  |  |  | #if TARGET_OS_IOS | 
|---|
|  |  |  | #import <TargetConditionals.h> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #if TARGET_OS_IOS || TARGET_OS_TV | 
|---|
|  |  |  | #import <UIKit/UIKit.h> | 
|---|
|  |  |  | #elif TARGET_OS_WATCH | 
|---|
|  |  |  | #import <WatchKit/WatchKit.h> | 
|---|
|  |  |  | #endif | 
|---|
|  |  |  |  | 
|---|
|  |  |  | NS_ASSUME_NONNULL_BEGIN | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | Returns a percent-escaped string following RFC 3986 for a query string key or value. | 
|---|
|  |  |  | RFC 3986 states that the following characters are "reserved" characters. | 
|---|
|  |  |  | - General Delimiters: ":", "#", "[", "]", "@", "?", "/" | 
|---|
|  |  |  | - Sub-Delimiters: "!", "$", "&", "'", "(", ")", "*", "+", ",", ";", "=" | 
|---|
|  |  |  |  | 
|---|
|  |  |  | In RFC 3986 - Section 3.4, it states that the "?" and "/" characters should not be escaped to allow | 
|---|
|  |  |  | query strings to include a URL. Therefore, all "reserved" characters with the exception of "?" and "/" | 
|---|
|  |  |  | should be percent-escaped in the query string. | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @param string The string to be percent-escaped. | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @return The percent-escaped string. | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | FOUNDATION_EXPORT NSString * AFPercentEscapedStringFromString(NSString *string); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | A helper method to generate encoded url query parameters for appending to the end of a URL. | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @param parameters A dictionary of key/values to be encoded. | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @return A url encoded query string | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | FOUNDATION_EXPORT NSString * AFQueryStringFromParameters(NSDictionary *parameters); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | The `AFURLRequestSerialization` protocol is adopted by an object that encodes parameters for a specified HTTP requests. Request serializers may encode parameters as query strings, HTTP bodies, setting the appropriate HTTP header fields as necessary. | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | - (nullable NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request | 
|---|
|  |  |  | withParameters:(nullable id)parameters | 
|---|
|  |  |  | error:(NSError * __nullable __autoreleasing *)error; | 
|---|
|  |  |  | error:(NSError * _Nullable __autoreleasing *)error NS_SWIFT_NOTHROW; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @end | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @discussion To add or remove default request headers, use `setValue:forHTTPHeaderField:`. | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @property (readonly, nonatomic, strong) NSDictionary *HTTPRequestHeaders; | 
|---|
|  |  |  | @property (readonly, nonatomic, strong) NSDictionary <NSString *, NSString *> *HTTPRequestHeaders; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | Creates and returns a serializer with default configuration. | 
|---|
|  |  |  | 
|---|
|  |  |  | password:(NSString *)password; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | @deprecated This method has been deprecated. Use -setValue:forHTTPHeaderField: instead. | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | - (void)setAuthorizationHeaderFieldWithToken:(NSString *)token DEPRECATED_ATTRIBUTE; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | Clears any existing value for the "Authorization" HTTP header. | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | - (void)clearAuthorizationHeader; | 
|---|
|  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | HTTP methods for which serialized requests will encode parameters as a query string. `GET`, `HEAD`, and `DELETE` by default. | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @property (nonatomic, strong) NSSet *HTTPMethodsEncodingParametersInURI; | 
|---|
|  |  |  | @property (nonatomic, strong) NSSet <NSString *> *HTTPMethodsEncodingParametersInURI; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | Set the method of query string serialization according to one of the pre-defined styles. | 
|---|
|  |  |  | 
|---|
|  |  |  | ///------------------------------- | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | @deprecated This method has been deprecated. Use -requestWithMethod:URLString:parameters:error: instead. | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | - (NSMutableURLRequest *)requestWithMethod:(NSString *)method | 
|---|
|  |  |  | URLString:(NSString *)URLString | 
|---|
|  |  |  | parameters:(id)parameters DEPRECATED_ATTRIBUTE; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | Creates an `NSMutableURLRequest` object with the specified HTTP method and URL string. | 
|---|
|  |  |  |  | 
|---|
|  |  |  | If the HTTP method is `GET`, `HEAD`, or `DELETE`, the parameters will be used to construct a url-encoded query string that is appended to the request's URL. Otherwise, the parameters will be encoded according to the value of the `parameterEncoding` property, and set as the request body. | 
|---|
|  |  |  | 
|---|
|  |  |  | - (NSMutableURLRequest *)requestWithMethod:(NSString *)method | 
|---|
|  |  |  | URLString:(NSString *)URLString | 
|---|
|  |  |  | parameters:(nullable id)parameters | 
|---|
|  |  |  | error:(NSError * __nullable __autoreleasing *)error; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | @deprecated This method has been deprecated. Use -multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:error: instead. | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | - (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method | 
|---|
|  |  |  | URLString:(NSString *)URLString | 
|---|
|  |  |  | parameters:(NSDictionary *)parameters | 
|---|
|  |  |  | constructingBodyWithBlock:(void (^)(id <AFMultipartFormData> formData))block DEPRECATED_ATTRIBUTE; | 
|---|
|  |  |  | error:(NSError * _Nullable __autoreleasing *)error; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | Creates an `NSMutableURLRequest` object with the specified HTTP method and URLString, and constructs a `multipart/form-data` HTTP body, using the specified parameters and multipart form data block. See http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.2 | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | - (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method | 
|---|
|  |  |  | URLString:(NSString *)URLString | 
|---|
|  |  |  | parameters:(nullable NSDictionary *)parameters | 
|---|
|  |  |  | parameters:(nullable NSDictionary <NSString *, id> *)parameters | 
|---|
|  |  |  | constructingBodyWithBlock:(nullable void (^)(id <AFMultipartFormData> formData))block | 
|---|
|  |  |  | error:(NSError * __nullable __autoreleasing *)error; | 
|---|
|  |  |  | error:(NSError * _Nullable __autoreleasing *)error; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | Creates an `NSMutableURLRequest` by removing the `HTTPBodyStream` from a request, and asynchronously writing its contents into the specified file, invoking the completion handler when finished. | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | - (NSMutableURLRequest *)requestWithMultipartFormRequest:(NSURLRequest *)request | 
|---|
|  |  |  | writingStreamContentsToFile:(NSURL *)fileURL | 
|---|
|  |  |  | completionHandler:(nullable void (^)(NSError * __nullable error))handler; | 
|---|
|  |  |  | completionHandler:(nullable void (^)(NSError * _Nullable error))handler; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @end | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | - (BOOL)appendPartWithFileURL:(NSURL *)fileURL | 
|---|
|  |  |  | name:(NSString *)name | 
|---|
|  |  |  | error:(NSError * __nullable __autoreleasing *)error; | 
|---|
|  |  |  | error:(NSError * _Nullable __autoreleasing *)error; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the encoded file data and the multipart form boundary. | 
|---|
|  |  |  | 
|---|
|  |  |  | name:(NSString *)name | 
|---|
|  |  |  | fileName:(NSString *)fileName | 
|---|
|  |  |  | mimeType:(NSString *)mimeType | 
|---|
|  |  |  | error:(NSError * __nullable __autoreleasing *)error; | 
|---|
|  |  |  | error:(NSError * _Nullable __autoreleasing *)error; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the data from the input stream and the multipart form boundary. | 
|---|
|  |  |  | 
|---|
|  |  |  | @param headers The HTTP headers to be appended to the form data. | 
|---|
|  |  |  | @param body The data to be encoded and appended to the form data. This parameter must not be `nil`. | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | - (void)appendPartWithHeaders:(nullable NSDictionary *)headers | 
|---|
|  |  |  | - (void)appendPartWithHeaders:(nullable NSDictionary <NSString *, NSString *> *)headers | 
|---|
|  |  |  | body:(NSData *)body; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | `AFURLRequestSerializationErrorDomain` | 
|---|
|  |  |  | AFURLRequestSerializer errors. Error codes for `AFURLRequestSerializationErrorDomain` correspond to codes in `NSURLErrorDomain`. | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | extern NSString * const AFURLRequestSerializationErrorDomain; | 
|---|
|  |  |  | FOUNDATION_EXPORT NSString * const AFURLRequestSerializationErrorDomain; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | ## User info dictionary keys | 
|---|
|  |  |  | 
|---|
|  |  |  | `AFNetworkingOperationFailingURLRequestErrorKey` | 
|---|
|  |  |  | The corresponding value is an `NSURLRequest` containing the request of the operation associated with an error. This key is only present in the `AFURLRequestSerializationErrorDomain`. | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | extern NSString * const AFNetworkingOperationFailingURLRequestErrorKey; | 
|---|
|  |  |  | FOUNDATION_EXPORT NSString * const AFNetworkingOperationFailingURLRequestErrorKey; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | ## Throttling Bandwidth for HTTP Request Input Streams | 
|---|
|  |  |  | 
|---|
|  |  |  | `kAFUploadStream3GSuggestedDelay` | 
|---|
|  |  |  | Duration of delay each time a packet is read. Equal to 0.2 seconds. | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | extern NSUInteger const kAFUploadStream3GSuggestedPacketSize; | 
|---|
|  |  |  | extern NSTimeInterval const kAFUploadStream3GSuggestedDelay; | 
|---|
|  |  |  | FOUNDATION_EXPORT NSUInteger const kAFUploadStream3GSuggestedPacketSize; | 
|---|
|  |  |  | FOUNDATION_EXPORT NSTimeInterval const kAFUploadStream3GSuggestedDelay; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | NS_ASSUME_NONNULL_END | 
|---|