PHP cURL 返回 HTTP/1.1 100 Continue
来源:互联网 发布:债券投资 知乎 编辑:程序博客网 时间:2024/06/05 03:13
当PHP cURL 时,如果POST的数据部分超过了1024字节,发送POST请求时header部分会包含一个参数Expect:100-continue,询问服务器是否愿意接收数据,收到服务器返回的100-continue应答后再把数据POST给服务器。
在项目中遇到一个问题如下:
当传输的数据较少时,cURL拿到的返回是这样的
array(2) { ["header"]=> string(249) "HTTP/1.1 200 OKDate: Wed, 30 Mar 2016 05:24:27 GMTContent-Type: application/jsonContent-Length: 34Connection: keep-aliveVary: Accept-EncodingSet-Cookie: checkinfo=; expires=Tue, 31 Mar 2015 05:24:27 GMT; Path=/Server: TornadoServer/4.2" ["body"]=> string(30) "{"error_msg":"","is_succ":"1"}"}但是数据多后,拿到的返回是这样的
array(2) { ["header"]=> string(21) "HTTP/1.1 100 Continue" ["body"]=> string(249) "HTTP/1.1 200 OKDate: Wed, 30 Mar 2016 05:26:01 GMTContent-Type: application/jsonContent-Length: 34Connection: keep-aliveVary: Accept-EncodingSet-Cookie: checkinfo=; expires=Tue, 31 Mar 2015 05:26:01 GMT; Path=/Server: TornadoServer/4.2"}正常情况下,应该返回200 OK,但是数据过的情况下header是100 Continue,body中则为本应出现在header中的内容,接口对接方那边说数据成功收到了,说明POST成功了,但是"{"error_msg":"","is_succ":"1"}"这个理应出现的返回没了。
为了解决这个问题,上网查资料,发现在header中设置Expect为空即可。
curl_setopt( $curl_handle, CURLOPT_HTTPHEADER, array( 'Expect:' ) );
这样返回信息就正常了。
阅读全文
0 0
- PHP cURL 返回 HTTP/1.1 100 Continue
- PHP cURL 返回 HTTP/1.1 100 Continue
- HTTP/1.1协议的curl 返回 HTTP/1.1 100 Continue 加上header 加上body
- HTTP/1.1协议的curl 返回 HTTP/1.1 100 Continue 加上header 加上body
- http post curl Expect:100-continue
- HTTP/1.1 100 Continue
- curl Expect:100-continue
- Curl Expect:100-continue
- php curl http https
- PHP CURL HTTP研究
- PHP curl 不返回结果
- HTTP/1.1 协议Expect: 100-continue
- http之100-continue
- HTTP 之100-Continue
- PHP CURL HTTP 研究笔记
- php curl http 那些事
- PHP CURL GET HTTP CODE
- php http请求 curl方法
- 记一次分析解决ANR过程
- 手机号和邮箱正则匹配
- PHP微信接口签名算法
- 恶意代码分析实战 Lab16-01
- build.gradle详细配置分析
- PHP cURL 返回 HTTP/1.1 100 Continue
- redis随笔(二)----淘汰策略的原理以及实现
- jsp引入jquery报错
- HashMap底层之entrySet,keySet,value实现
- APP研发录笔记
- springmvc文件上传
- "=="和equals方法究竟有什么区别?
- 如何使用github找到自己感兴趣的项目
- 设计模式二:观察者模式(发布订阅模式)