|
20 | 20 | #import "QCloudXMLDictionary.h" |
21 | 21 | #import "QCloudEncryt.h" |
22 | 22 | #import "QCloudFileOffsetBody.h" |
| 23 | +#import "QCloudURLHelper.h" |
23 | 24 | NSString* const HTTPMethodPOST = @"POST"; |
24 | 25 | NSString* const HTTPMethodGET = @"GET"; |
25 | 26 | NSString* const HTTPHeaderHOST = @"HOST"; |
|
231 | 232 | }; |
232 | 233 |
|
233 | 234 |
|
| 235 | +NSString* QCloudURLFuseAllPathComponents(NSArray* componets) |
| 236 | +{ |
| 237 | + NSString* path = @""; |
| 238 | + for (NSString* com in componets) { |
| 239 | + if (com.length > 0) { |
| 240 | + path = QCloudPathJoin(path, com); |
| 241 | + } |
| 242 | + } |
| 243 | + path = QCloudPercentEscapedStringFromString(path); |
| 244 | + return path; |
| 245 | +} |
234 | 246 |
|
235 | 247 | QCloudRequestSerializerBlock QCloudURLFuseSimple = ^(NSMutableURLRequest* request, QCloudRequestData* data, NSError* __autoreleasing*error) { |
236 | | - NSString* path = QCloudPathJoin(data.serverURL, data.URIMethod); |
| 248 | + NSMutableArray* coms = [NSMutableArray new]; |
| 249 | + if(data.URIMethod.length) { |
| 250 | + [coms addObject:data.URIMethod]; |
| 251 | + } |
237 | 252 | if (data.URIComponents.count) { |
238 | | - for(int i = 0; i < data.URIComponents.count; i++) { |
239 | | - NSString* component = data.URIComponents[i]; |
240 | | - if (component.length > 0) { |
241 | | - path = QCloudPathJoin(path, component); |
242 | | - } |
243 | | - } |
| 253 | + [coms addObjectsFromArray:data.URIComponents]; |
244 | 254 | } |
| 255 | + NSString* path = QCloudURLFuseAllPathComponents(coms); |
| 256 | + path = QCloudPathJoin(data.serverURL, path); |
245 | 257 | NSURL* url = [NSURL URLWithString:path]; |
246 | 258 | if (nil == url) { |
247 | | - url = [NSURL URLWithString:QCloudEncodeURL(path)]; |
| 259 | + url = [NSURL URLWithString:QCloudURLEncodeUTF8(path)]; |
248 | 260 | } |
249 | 261 | NSMutableURLRequest* urlRequest = [[NSMutableURLRequest alloc] initWithURL:url]; |
250 | 262 | return urlRequest; |
|
297 | 309 |
|
298 | 310 |
|
299 | 311 | QCloudRequestSerializerBlock QCloudURLFuseURIMethodASURLParamters = ^(NSMutableURLRequest* request, QCloudRequestData* data, NSError* __autoreleasing*error) { |
| 312 | + |
300 | 313 | NSString* urlStr = nil; |
301 | 314 | if (request.URL.absoluteString.length > 0) { |
302 | 315 | urlStr = request.URL.absoluteString; |
303 | 316 | } else { |
304 | 317 | urlStr = data.serverURL; |
| 318 | + NSMutableArray* coms = [NSMutableArray new]; |
305 | 319 | if (data.URIComponents.count) { |
306 | | - for(int i = 0; i < data.URIComponents.count; i++) { |
307 | | - NSString* component = data.URIComponents[i]; |
308 | | - if (component.length > 0) { |
309 | | - urlStr = QCloudPathJoin(urlStr, component); |
310 | | - } |
311 | | - } |
| 320 | + [coms addObjectsFromArray:data.URIComponents]; |
312 | 321 | } |
| 322 | + NSString* path = QCloudURLFuseAllPathComponents(coms); |
| 323 | + urlStr = QCloudPathJoin(urlStr, path); |
313 | 324 | } |
| 325 | + |
314 | 326 | NSMutableDictionary* methodParamters = [NSMutableDictionary new]; |
315 | 327 | if (data.URIMethod) { |
316 | 328 | methodParamters[data.URIMethod] = @""; |
|
0 commit comments