Conditionally adding default user agent header
This commit is contained in:
parent
b626edf490
commit
e46b9e620b
1 changed files with 17 additions and 8 deletions
|
|
@ -20,11 +20,18 @@
|
|||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#import "AFHTTPClient.h"
|
||||
#import "AFJSONRequestOperation.h"
|
||||
#import "JSONKit.h"
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#include <Availability.h>
|
||||
#import "AFHTTPClient.h"
|
||||
#import "AFHTTPRequestOperation.h"
|
||||
|
||||
#import <Availability.h>
|
||||
|
||||
#if __IPHONE_OS_VERSION_MIN_REQUIRED
|
||||
#import <UIKit/UIKit.h>
|
||||
#endif
|
||||
|
||||
#import "JSONKit.h"
|
||||
|
||||
static NSString * const kAFMultipartFormLineDelimiter = @"\r\n"; // CRLF
|
||||
static NSString * const kAFMultipartFormBoundary = @"Boundary+0xAbCdEfGbOuNdArY";
|
||||
|
|
@ -93,7 +100,7 @@ static NSString * AFQueryStringFromParameters(NSDictionary *parameters) {
|
|||
static NSString * AFJSONStringFromParameters(NSDictionary *parameters) {
|
||||
NSString *JSONString = nil;
|
||||
|
||||
#if __IPHONE_OS_VERSION_MIN_REQUIRED > __IPHONE_4_3
|
||||
#if __IPHONE_OS_VERSION_MIN_REQUIRED > __IPHONE_4_3 || __MAC_OS_X_VERSION_MIN_REQUIRED > __MAC_10_6
|
||||
if ([NSJSONSerialization class]) {
|
||||
NSError *error = nil;
|
||||
NSData *JSONData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:&error];
|
||||
|
|
@ -165,9 +172,11 @@ static NSString * AFPropertyListStringFromParameters(NSDictionary *parameters) {
|
|||
// Accept-Language HTTP Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4
|
||||
NSString *preferredLanguageCodes = [[NSLocale preferredLanguages] componentsJoinedByString:@", "];
|
||||
[self setDefaultHeader:@"Accept-Language" value:[NSString stringWithFormat:@"%@, en-us;q=0.8", preferredLanguageCodes]];
|
||||
|
||||
// // User-Agent Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43
|
||||
// [self setDefaultHeader:@"User-Agent" value:[NSString stringWithFormat:@"%@/%@ (%@, %@ %@, %@, Scale/%f)", [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleIdentifierKey], [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleVersionKey], @"unknown", [[UIDevice currentDevice] systemName], [[UIDevice currentDevice] systemVersion], [[UIDevice currentDevice] model], ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] ? [[UIScreen mainScreen] scale] : 1.0)]];
|
||||
|
||||
#if __IPHONE_OS_VERSION_MIN_REQUIRED
|
||||
// User-Agent Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43
|
||||
[self setDefaultHeader:@"User-Agent" value:[NSString stringWithFormat:@"%@/%@ (%@, %@ %@, %@, Scale/%f)", [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleIdentifierKey], [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleVersionKey], @"unknown", [[UIDevice currentDevice] systemName], [[UIDevice currentDevice] systemVersion], [[UIDevice currentDevice] model], ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] ? [[UIScreen mainScreen] scale] : 1.0)]];
|
||||
#endif
|
||||
|
||||
self.operationQueue = [[[NSOperationQueue alloc] init] autorelease];
|
||||
[self.operationQueue setMaxConcurrentOperationCount:kAFHTTPClientDefaultMaxConcurrentOperationCount];
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue