Post请求有问题...
Closed this issue · 1 comments
作者所有的Post请求都是使用如下方法
request.sessionTask = [manager POST:request.requestUrl parameters:request.requestArgument constructingBodyWithBlock:request.constructingBodyBlock progress:request.resumableUploadProgressBlock success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
__strong __typeof(weakSelf) self = weakSelf;
[self handleRequestResult:task responseObject:responseObject error:nil];
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
__strong __typeof(weakSelf) self = weakSelf;
[self handleRequestResult:task responseObject:nil error:error];
}];
当我不需要在请求体里面添加参数,使用默认的方法返回nil
-
(CCConstructingBlock)constructingBodyBlock { return nil; }
报错如下:
{ status code: 200, headers {
Connection = "keep-alive";
"Content-Length" = 236;
"Content-Type" = "text/html;charset=UTF-8";
Date = "Sat, 03 Sep 2016 08:43:40 GMT";
Server = "nginx/1.9.15";
"Set-Cookie" = "JSESSIONID=9D69EAC9F867C45E3412A00D9A766F63; Path=/passport-web/; HttpOnly";
} }
error:
Domain: cn.com.CCREQEST
Code: 3840
Localized: 服务器异常,请稍后再试
UserInfo: {
}
而我吧Post方法替换成
request.sessionTask = [manager POST:request.requestUrl parameters:request.requestArgument progress:^(NSProgress * _Nonnull uploadProgress) {} success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { __strong __typeof(weakSelf) self = weakSelf; [self handleRequestResult:task responseObject:responseObject error:nil]; } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { __strong __typeof(weakSelf) self = weakSelf; [self handleRequestResult:task responseObject:nil error:error]; }];
则请求正常
AF中
[manager POST:<#(nonnull NSString *)#> parameters:<#(nullable id)#> progress:<#^(NSProgress * _Nonnull uploadProgress)uploadProgress#> success:<#^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject)success#> failure:<#^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error)failure#>]
与
[manager POST:<#(nonnull NSString *)#> parameters:<#(nullable id)#> constructingBodyWithBlock:<#^(id _Nonnull formData)block#> progress:<#^(NSProgress * _Nonnull uploadProgress)uploadProgress#> success:<#^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject)success#> failure:<#^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error)failure#>]
这两个方法,最终进入的方法是不一样的
不知道是不是作者的源码CCRequestDispatchCenter.m中的Post请求调用的方法存在问题???
十分抱歉,事先为考虑到后端架构有可能不支持http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.2
现在已经按您提供的思路处理.