用curl进行post数据出现Expect: 100-continue错误

来源:互联网 发布:js 选项卡 编辑:程序博客网 时间:2024/06/08 02:20

问题:用curl测试php的上传文件接口

curl.exe -F"username=zdz" -F "password=123456" -F filename=@AAA.rar http://192.168.0.22/modules/index.php

返回包含‘Expectationfailed’的html信息。

解决:发现是因为php的http服务器是用lighttp,用appache就没有这个错误。

查询一下说是lighttpd v1.4.x不支持“Expect: 100-continue”HTTP头

有三个解决方法:

1、用lighttp 1.50

2、curl改用-d参数post表单,即:

curl.exe -d "username=zdz" -d "password=123456"-d filename=@AAA.rar http://192.168.0.22/modules/index.php,但只能上传普通的表单,无法带文件上传的表单。

3、我的用是v1.4.28,lighttpd 1.4.21或以上版本(即最新的realease版本),只要在lighttpd配置文件中加入server.reject-expect-100-with-417="disable"即可

来自东子的博客
原创粉丝点击