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 | 10 | |
| 11 | 11 | @interface CNLiveUserURLRequestSerialization : NSObject |
| 12 | 12 | |
| 13 | -+ (nullable NSString *)CNQueryStringFromParameters:(nullable NSDictionary *)parameters; | |
| 13 | ++ (nullable NSString *)CNUserQueryStringFromParameters:(nullable NSDictionary *)parameters; | |
| 14 | 14 | |
| 15 | 15 | @end | ... | ... |
CNLiveUserSystemDemo/CNLiveNetworking/CNLiveURLRequestSerialization.m
| ... | ... | @@ -35,27 +35,27 @@ |
| 35 | 35 | |
| 36 | 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 | 43 | NSMutableArray *mutablePairs = [NSMutableArray array]; |
| 44 | - for (CNLiveUserURLRequestSerialization *pair in CNQueryStringPairsFromDictionary(parameters)) { | |
| 44 | + for (CNLiveUserURLRequestSerialization *pair in CNUserQueryStringPairsFromDictionary(parameters)) { | |
| 45 | 45 | [mutablePairs addObject:[pair URLEncodedStringValue]]; |
| 46 | 46 | } |
| 47 | 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 | 60 | NSMutableArray *mutableQueryStringComponents = [NSMutableArray array]; |
| 61 | 61 | |
| ... | ... | @@ -67,7 +67,7 @@ NSArray * CNQueryStringPairsFromKeyAndValue(NSString *key, id value) |
| 67 | 67 | for (id nestedKey in [dictionary.allKeys sortedArrayUsingDescriptors:@[sortDescriptor]]) { |
| 68 | 68 | id nestedValue = dictionary[nestedKey]; |
| 69 | 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 | 75 | else if ([value isKindOfClass:[NSArray class]]){ //数组 |
| 76 | 76 | NSArray *array = value; |
| 77 | 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 | 80 | }else if ([value isKindOfClass:[NSSet class]]){ //集合 |
| 81 | 81 | NSSet *set = value; |
| 82 | 82 | for (id obj in [set sortedArrayUsingDescriptors:@[ sortDescriptor ]]) { |
| 83 | - [mutableQueryStringComponents addObjectsFromArray:CNQueryStringPairsFromKeyAndValue(key, obj)]; | |
| 83 | + [mutableQueryStringComponents addObjectsFromArray:CNUserQueryStringPairsFromKeyAndValue(key, obj)]; | |
| 84 | 84 | } |
| 85 | 85 | }else{ //其他类型 |
| 86 | 86 | [mutableQueryStringComponents addObject:[[CNLiveUserURLRequestSerialization alloc] initWithField:key value:value]]; | ... | ... |
CNLiveUserSystemDemo/CNLiveNetworking/CNLiveUserNetworkManager.m
| ... | ... | @@ -89,7 +89,7 @@ static NSURLRequestCachePolicy CachePolicy = NSURLRequestUseProtocolCachePolicy; |
| 89 | 89 | NSString *newURLString; |
| 90 | 90 | if ([method isEqualToString:@"GET"]) { |
| 91 | 91 | if (parameters) { |
| 92 | - newURLString = [[URLString stringByAppendingString:@"?"] stringByAppendingString:[CNLiveUserURLRequestSerialization CNQueryStringFromParameters:parameters]]; | |
| 92 | + newURLString = [[URLString stringByAppendingString:@"?"] stringByAppendingString:[CNLiveUserURLRequestSerialization CNUserQueryStringFromParameters:parameters]]; | |
| 93 | 93 | }else{ |
| 94 | 94 | newURLString = URLString; |
| 95 | 95 | } |
| ... | ... | @@ -104,7 +104,7 @@ static NSURLRequestCachePolicy CachePolicy = NSURLRequestUseProtocolCachePolicy; |
| 104 | 104 | if([method isEqual:@"POST"]){ |
| 105 | 105 | if (!data) { |
| 106 | 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 | 108 | } else { |
| 109 | 109 | //设置HTTPHeader中Content-Type的值 |
| 110 | 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