ASI框架设置Content-Type无效的问题
来源:互联网 发布:众安保险尊享e生 知乎 编辑:程序博客网 时间:2024/06/06 20:13
我服务器的某些接口只接收Content-Type 为“application/x-protobuf”的访问,我是用ASIFormDataRequest向服务器发送数据,通过addRequestHeader:value:方法设置Content-Type,结果总是不成功,在服务器端发现收到的Content-Type为“application/octet-stream”,后来经过多番尝试,通过使用setRequestHeaders:批量设置http头可以生效,在此记录以下,代码如下,注释掉的部分就是不起效的。
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:nsurl]; [request setRequestMethod:@"POST"]; [request setPostBody:[cmtBuilder.build data]]; //通过以下设置content-type的方式不起效// [request addRequestHeader:@"application/x-protobuf" value:@"Content-Type"];// [request addRequestHeader:@"application/x-protobuf" value:@"Accept"]; //通过如下方式才可以 NSMutableDictionary *header = [[NSMutableDictionary alloc] init]; [header setValue:@"application/x-protobuf" forKey:@"Content-Type"]; [header setValue:@"application/x-protobuf" forKey:@"Accept"]; [request setRequestHeaders:header]; //启动同步访问 [request startSynchronous];
- ASI框架设置Content-Type无效的问题
- 关于OkHttp设置Content-Type问题
- ASI框架的使用
- Yii框架无法设置Content-Type之谜
- 设置content type
- OkHttp3设置Content-Type
- OkHttp3设置Content-Type
- 设置正确的Content-Type以解决Ext的中文乱码问题
- 一个content-type引发的问题
- php中利用header设置content-type和常见文件类型的content-type
- php中利用header设置content-type和常见文件类型的content-type
- ASI框架
- php的header函数之设置content-type
- php的header函数之设置content-type
- php的header函数之设置content-type
- php的header函数之设置content-type
- php的header函数之设置content-type
- php的header函数之设置content-type
- 性能监控工具JavaMelody的使用
- adf 常用el 参数
- C#调用WebService
- hdu 1171 Big Event in HDU 多重背包
- Eclipse和MyEclipse下安装jad
- ASI框架设置Content-Type无效的问题
- MiniDao持久层 Vs Mybatis
- 怎么把自己的windows7电脑做无线发射器
- 8.4 内部排序法---归并类排序
- hdu4708
- 深度优先搜索
- 竖直滑动的viewpager-------VerticalAdapter
- requestDisallowInterceptTouchEvent
- POJ 2175 spfa费用流消圈