I had to work with a PHP-application using the CURL library to send a HTTP POST request to a lighttpd server or apache server.
Strangely enough I seemed unable to get anything back from the server when using PHP and I got the correct answer when I was using wget as a reference.
This made me check the lightpd log and I once more (I recommend you to read that entry as this is very much dependent on it) came across the friendly error 417
A quick check with Wireshark confirmed: curl was sending the Expect: 100-continue header.
Personally, I think that 100-continue thing is a good thing and it even seems to me that the curl library is intelligent about it and only does that thing when the size of the data to send is larger than a certain threshold.
Also, even though people are complaining about it, I think lighttpd does the right thing. The expect-header is mandatory and if lighttpd doesn't support this particular header, the error 417 is the only viable option.
What I think though is that the libraries should detect that automatically.
This is because they are creating a behavior that's not consistent to the other types of request: GET, DELETE and HEAD requests all follow a fire-and-forget paradigm and the libraries employ a 1:1 mapping: Set up the request. Send it. Return the received data.
With POST (and maybe PUT), the library changes that paradigm and in fact sends two request to the wire while actually pretending in the interface that it's only sending one request.
If it does that, then it should at least be capable enough to handle the cases where their scheme of transparently changing semantics breaks.
If you are doing a POST, and the content length is 1,025 or greater, then curl exploits a feature of http 1.1: 100 (Continue) Status.
See http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html#sec8.2.3
* it adds a header, "Expect: 100-continue".
* it then sends the request head, waits for a 100 response code, then sends the content
Not all web servers support this though. Various errors are returned depending on the server. If this happens to you, suppress the "Expect" header with this command:
<?php
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
?>
See http://www.gnegg.ch/2007/02/the-return-of-except-100-continue/
Also, you should check your libcurl version. whether it's the latest 0.7 or not? if not, please use the latest one to your site.
分享到:
相关推荐
本文实例讲述了php使用curl出现Expect:100-continue解决方法。分享给大家供大家参考。具体如下: 使用curl POST数据时,如果POST的数据大于1024字节,curl并不会直接就发起POST请求。而是会分两步。 1.发送一个请求...
curl-8.4.0_3-win32-mingw.zip curl-8.4.0_3-win64-mingw.zip curl-8.4.0_3-win64a-mingw.zip
curl-7.42.0-win64.zip
curl-7.76.1-win64-mingw.zip
curl-7.68.0-win64-mingw.zip windows curl curl-7.68.0-win64-mingw curl-7.68.0-win64-mingw
curl 工具 window 64位 curl-7.71.1-win64-mingw.zip
curl-7.78.0-win64-mingw.zip
欢迎下载curl-7.21.0-win64-ssl-sspi 工具,有其他工具需要随时沟通,
curl 版本 7.56.0-win64-mingw 解压版,支持 SSL,SSH
curl是利用URL语法在命令行方式下工作的开源文件传输工具。它被广泛应用在Unix、多种Linux发行版中,并且有DOS和Win32、Win64...curl-7.53.1-win64-mingw.7z。windows的curl.exe。直接在当前目录下的cmd中执行curl即可
cURL是一个利用URL语法在命令行下工作的文件传输工具,1997年首次发行。它支持文件上传和下载,所以是综合传输工具,但按传统,习惯称cURL为下载工具
最新 windows 64 位稳定版 c++一个跨平台的网络协议库,支持http, https, ftp, gopher, telnet, dict, file, 和ldap 协议。同样支持HTTPS证书授权,HTTP POST, HTTP PUT, FTP 上传, HTTP基本表单上传,代理,cookies...
如果是 Windows 系统,下载 window 版本(curl-7.33.0-win64-ssl-sspi.zip解压后的curl.exe文件,添加到环境变量中,以便在其他路径中通过cmd窗口使用curl命令): 如果你安装了 git shell,也自带了 curl。
latest curl-7.61.1_6-win32-mingw, downloaded from https://curl.haxx.se/download.html
perl-WWW-Curl4.17版本rpm包
curl-7.53.1-win64-mingw.7z。windows的curl.exe。直接在当前目录下的cmd中执行curl即可
100 power solutions to real-world problems This practical guide gives you 100 ready-to-run ...
curl-7.48.0-win64-mingw
下载完成后,解压压缩包,拷贝到需要安装的文件加下,打开doc命令窗口,cd到bin目录,然后执行curl --help,打印出帮助信息则安装成功