Commit f4b838c036f99ebb1503c3a611c0d73f0141bfb9
1 parent
6a5ab4f2
修改CNLiveUserURLRequestSerialization
Showing
5 changed files
with
13 additions
and
13 deletions
CNLiveUserSystemDemo/CNLiveNetworking/CNLiveURLRequestSerialization.h
| @@ -10,6 +10,6 @@ | @@ -10,6 +10,6 @@ | ||
| 10 | 10 | ||
| 11 | @interface CNLiveUserURLRequestSerialization : NSObject | 11 | @interface CNLiveUserURLRequestSerialization : NSObject |
| 12 | 12 | ||
| 13 | -+ (nullable NSString *)CNQueryStringFromParameters:(nullable NSDictionary *)parameters; | 13 | ++ (nullable NSString *)CNUserQueryStringFromParameters:(nullable NSDictionary *)parameters; |
| 14 | 14 | ||
| 15 | @end | 15 | @end |
CNLiveUserSystemDemo/CNLiveNetworking/CNLiveURLRequestSerialization.m
| @@ -35,27 +35,27 @@ | @@ -35,27 +35,27 @@ | ||
| 35 | 35 | ||
| 36 | #pragma mark - | 36 | #pragma mark - |
| 37 | 37 | ||
| 38 | -FOUNDATION_EXPORT NSArray * CNQueryStringPairsFromDictionary(NSDictionary *dictionary); | ||
| 39 | -FOUNDATION_EXPORT NSArray * CNQueryStringPairsFromKeyAndValue(NSString *key, id value); | 38 | +FOUNDATION_EXPORT NSArray * CNUserQueryStringPairsFromDictionary(NSDictionary *dictionary); |
| 39 | +FOUNDATION_EXPORT NSArray * CNUserQueryStringPairsFromKeyAndValue(NSString *key, id value); | ||
| 40 | 40 | ||
| 41 | -+ (NSString *)CNQueryStringFromParameters:(NSDictionary *)parameters | 41 | ++ (NSString *)CNUserQueryStringFromParameters:(NSDictionary *)parameters |
| 42 | { | 42 | { |
| 43 | NSMutableArray *mutablePairs = [NSMutableArray array]; | 43 | NSMutableArray *mutablePairs = [NSMutableArray array]; |
| 44 | - for (CNLiveUserURLRequestSerialization *pair in CNQueryStringPairsFromDictionary(parameters)) { | 44 | + for (CNLiveUserURLRequestSerialization *pair in CNUserQueryStringPairsFromDictionary(parameters)) { |
| 45 | [mutablePairs addObject:[pair URLEncodedStringValue]]; | 45 | [mutablePairs addObject:[pair URLEncodedStringValue]]; |
| 46 | } | 46 | } |
| 47 | return [mutablePairs componentsJoinedByString:@"&"]; | 47 | return [mutablePairs componentsJoinedByString:@"&"]; |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | -NSArray * CNQueryStringPairsFromDictionary(NSDictionary *dictionary) | 50 | +NSArray * CNUserQueryStringPairsFromDictionary(NSDictionary *dictionary) |
| 51 | { | 51 | { |
| 52 | - return CNQueryStringPairsFromKeyAndValue(nil, dictionary); | 52 | + return CNUserQueryStringPairsFromKeyAndValue(nil, dictionary); |
| 53 | } | 53 | } |
| 54 | 54 | ||
| 55 | /** | 55 | /** |
| 56 | * 处理上传参数 | 56 | * 处理上传参数 |
| 57 | */ | 57 | */ |
| 58 | -NSArray * CNQueryStringPairsFromKeyAndValue(NSString *key, id value) | 58 | +NSArray * CNUserQueryStringPairsFromKeyAndValue(NSString *key, id value) |
| 59 | { | 59 | { |
| 60 | NSMutableArray *mutableQueryStringComponents = [NSMutableArray array]; | 60 | NSMutableArray *mutableQueryStringComponents = [NSMutableArray array]; |
| 61 | 61 | ||
| @@ -67,7 +67,7 @@ NSArray * CNQueryStringPairsFromKeyAndValue(NSString *key, id value) | @@ -67,7 +67,7 @@ NSArray * CNQueryStringPairsFromKeyAndValue(NSString *key, id value) | ||
| 67 | for (id nestedKey in [dictionary.allKeys sortedArrayUsingDescriptors:@[sortDescriptor]]) { | 67 | for (id nestedKey in [dictionary.allKeys sortedArrayUsingDescriptors:@[sortDescriptor]]) { |
| 68 | id nestedValue = dictionary[nestedKey]; | 68 | id nestedValue = dictionary[nestedKey]; |
| 69 | if (nestedKey) { | 69 | if (nestedKey) { |
| 70 | - [mutableQueryStringComponents addObjectsFromArray:CNQueryStringPairsFromKeyAndValue((key ? [NSString stringWithFormat:@"%@[%@]", key, nestedKey] : nestedKey), nestedValue)]; | 70 | + [mutableQueryStringComponents addObjectsFromArray:CNUserQueryStringPairsFromKeyAndValue((key ? [NSString stringWithFormat:@"%@[%@]", key, nestedKey] : nestedKey), nestedValue)]; |
| 71 | } | 71 | } |
| 72 | } | 72 | } |
| 73 | } | 73 | } |
| @@ -75,12 +75,12 @@ NSArray * CNQueryStringPairsFromKeyAndValue(NSString *key, id value) | @@ -75,12 +75,12 @@ NSArray * CNQueryStringPairsFromKeyAndValue(NSString *key, id value) | ||
| 75 | else if ([value isKindOfClass:[NSArray class]]){ //数组 | 75 | else if ([value isKindOfClass:[NSArray class]]){ //数组 |
| 76 | NSArray *array = value; | 76 | NSArray *array = value; |
| 77 | for (id nestedValue in array) { | 77 | for (id nestedValue in array) { |
| 78 | - [mutableQueryStringComponents addObjectsFromArray:CNQueryStringPairsFromKeyAndValue([NSString stringWithFormat:@"%@[]", key], nestedValue)]; | 78 | + [mutableQueryStringComponents addObjectsFromArray:CNUserQueryStringPairsFromKeyAndValue([NSString stringWithFormat:@"%@[]", key], nestedValue)]; |
| 79 | } | 79 | } |
| 80 | }else if ([value isKindOfClass:[NSSet class]]){ //集合 | 80 | }else if ([value isKindOfClass:[NSSet class]]){ //集合 |
| 81 | NSSet *set = value; | 81 | NSSet *set = value; |
| 82 | for (id obj in [set sortedArrayUsingDescriptors:@[ sortDescriptor ]]) { | 82 | for (id obj in [set sortedArrayUsingDescriptors:@[ sortDescriptor ]]) { |
| 83 | - [mutableQueryStringComponents addObjectsFromArray:CNQueryStringPairsFromKeyAndValue(key, obj)]; | 83 | + [mutableQueryStringComponents addObjectsFromArray:CNUserQueryStringPairsFromKeyAndValue(key, obj)]; |
| 84 | } | 84 | } |
| 85 | }else{ //其他类型 | 85 | }else{ //其他类型 |
| 86 | [mutableQueryStringComponents addObject:[[CNLiveUserURLRequestSerialization alloc] initWithField:key value:value]]; | 86 | [mutableQueryStringComponents addObject:[[CNLiveUserURLRequestSerialization alloc] initWithField:key value:value]]; |
CNLiveUserSystemDemo/CNLiveNetworking/CNLiveUserNetworkManager.m
| @@ -89,7 +89,7 @@ static NSURLRequestCachePolicy CachePolicy = NSURLRequestUseProtocolCachePolicy; | @@ -89,7 +89,7 @@ static NSURLRequestCachePolicy CachePolicy = NSURLRequestUseProtocolCachePolicy; | ||
| 89 | NSString *newURLString; | 89 | NSString *newURLString; |
| 90 | if ([method isEqualToString:@"GET"]) { | 90 | if ([method isEqualToString:@"GET"]) { |
| 91 | if (parameters) { | 91 | if (parameters) { |
| 92 | - newURLString = [[URLString stringByAppendingString:@"?"] stringByAppendingString:[CNLiveUserURLRequestSerialization CNQueryStringFromParameters:parameters]]; | 92 | + newURLString = [[URLString stringByAppendingString:@"?"] stringByAppendingString:[CNLiveUserURLRequestSerialization CNUserQueryStringFromParameters:parameters]]; |
| 93 | }else{ | 93 | }else{ |
| 94 | newURLString = URLString; | 94 | newURLString = URLString; |
| 95 | } | 95 | } |
| @@ -104,7 +104,7 @@ static NSURLRequestCachePolicy CachePolicy = NSURLRequestUseProtocolCachePolicy; | @@ -104,7 +104,7 @@ static NSURLRequestCachePolicy CachePolicy = NSURLRequestUseProtocolCachePolicy; | ||
| 104 | if([method isEqual:@"POST"]){ | 104 | if([method isEqual:@"POST"]){ |
| 105 | if (!data) { | 105 | if (!data) { |
| 106 | [request addValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; | 106 | [request addValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; |
| 107 | - request.HTTPBody =[[CNLiveUserURLRequestSerialization CNQueryStringFromParameters:parameters] dataUsingEncoding:NSUTF8StringEncoding]; | 107 | + request.HTTPBody =[[CNLiveUserURLRequestSerialization CNUserQueryStringFromParameters:parameters] dataUsingEncoding:NSUTF8StringEncoding]; |
| 108 | } else { | 108 | } else { |
| 109 | //设置HTTPHeader中Content-Type的值 | 109 | //设置HTTPHeader中Content-Type的值 |
| 110 | NSString *content=[[NSString alloc]initWithFormat:@"multipart/form-data; boundary=%@",boundary]; | 110 | NSString *content=[[NSString alloc]initWithFormat:@"multipart/form-data; boundary=%@",boundary]; |
Products/CNLiveUserSystemSDK.framework/CNLiveUserSystemSDK
No preview for this file type
Products/CNLiveUserSystemSDK.framework/Info.plist
No preview for this file type