请求头
luo-h opened this issue · 8 comments
请问下我有些请求需要设置请求头,有些请求不需要设置请求头,这个应该怎么处理呢
NSMutableDictionary *dictHeaders = [self ba_headerParamters]; NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration]; [config setHTTPAdditionalHeaders:dictHeaders];
具体添加可以放数组里面,举个🌰:
`
NSMutableDictionary *paramters = [[NSMutableDictionary alloc] init];
[paramters setObject:@"gzip,deflate" forKey:@"Accept-encoding"];
[paramters setObject:header.platform forKey:@"platform"];
[paramters setObject:header.osVersion forKey:@"osVersion"];
`
我现在是直接把请求头设置在了你的+ (AFHTTPSessionManager *)sharedAFManager这个单列里面,但是如果我中途重新登录账号导致我需要更换这个请求头,怎么让单列重建,请问这个应该怎么处理
在不,我新版本可以支持自定义请求头了,怎么联系你?
你好、我QQ:657400689
楼主,你的demo为什么上传文件失败?我的地址:http://master.sensetime.com/api/v1/video/tag_miaopai
上传视频失败 = Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: bad request (400)" UserInfo={com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x170028020> { URL: http://master.sensetime.com/api/v1/video/tag_miaopai } { status code: 400, headers {
Connection = "keep-alive";
"Content-Length" = 72;
"Content-Type" = "application/json; charset=utf-8";
Date = "Tue, 13 Jun 2017 14:19:40 GMT";
Server = "nginx/1.11.4";
} }, NSErrorFailingURLKey=http://master.sensetime.com/api/v1/video/tag_miaopai, com.alamofire.serialization.response.error.data=<7b226572 726f725f 636f6465 223a2232 30303030 3130222c 22657272 6f72223a 224e6f20 66696c65 20776173 2075706c 6f616465 64222c22 73746174 7573223a 22657272 6f72227d>, NSLocalizedDescription=Request failed: bad request (400)}
2017-06-13 22:19:40.534622+0800 BANetManager[7985:295080] Failed
error in connection_block_invoke_2: Connection interrupted
群里 有个demo,是调试好的,你可以去下,不过这些情况要和后台一起调试,不一定都是前段问题!
这个新版本增加删除请求头的方法了,可以在单独页面增加后,在 离开页面的时候清空!