Lighttpd Expect 100-Continue Workaround
I need to support multiple file uploads through a Django web application which is running as a FCGI service behind lighttpd 1.4 (FC5). However the file upload Flash widgets which I’m using (both from http://swfupload.mammon.se/ and http://www.element-it.com/MultiPowUpload.aspx) fails to upload any file without any observed errors.
I have done a ethereal TCP dump on the HTTP communication and discovered that the Flash widget will send an additional HTTP header (Expect: 100-Continue) with the POST request, and lighttpd will always give a 417 Bad Expectation HTTP response.
My Workaround
Note: If you are using lighttpd 1.4, you are at a dead end; they are not going to fix this in lighttpd 1.4. (Details)
I have tried upgrading to lighttpd 1.5 (check out from SVN, compile, etc), but I still can’t get it to work. At this point in time (May 2007), lighttpd 1.5 is not ready for production.
Hence, I went back to my good, old Apache HTTP service.
Download mod_fcgi for Apache from http://www.fastcgi.com/. Compile and install. Note that I’m using FC5 and FC6 on my servers. If you are using other distros, mod_fcgi may be available as a pre-built package or have been installed on your machine.
Then, edit Apache configuration.
NameVirtualHost *:80
<virtualhost>
ServerName www.mydomain.com
DocumentRoot /var/www
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/(.*)$ /a.fcgi/web/$1 [QSA,L]
</virtualhost>
LoadModule fastcgi_module modules/mod_fastcgi.so
FastCgiExternalServer /var/www/a.fcgi -socket /tmp/fcgi-mydjango.sock
I’m using virtual hosting because there are other domains running on this server as well. Once the editing is done, restart the Apache HTTP service, and the Django web application should work.
Other Workarounds
If you are stuck with lighttpd (probably you need to use its anti-hotlink modules, etc), you can try running Apache on other ports like port 81 with lighttpd using port 80. Then modify your Django web application to always submit file upload requests to port 81 while having other web pages retrieved from port 80.
























[...] 1.1的文档,最后发现,lighttpd 1.4版本更本不会支持Expect: 100-continue这个HTTP头。或者装 lighttpd 1.5.x [...]
Thanks for explaining this, it’s the exact same problem I just ran into when trying to get the YUI Uploader to work.
Oddly enough, I just ran into this exact same problem and found your page after googling “flash upload 417 100-continue”, since I figured out this was the problem. But changing my server won’t help: my server actually handles the Expect correctly, but the network I’m currently sitting on (a Tully’s Coffee store) adds a proxy server (Mikrotik HttpProxy, according to the Server header) which does not. So my users can’t use my upload widget from Tully’s. Off to look for a workaround…
@NT:
HTTP proxies should only buffer downstream data and not intefere with upstream POSTs. Complain to Mikrotik on this. Another way is to use HTTPS. Proxies can’t intercept the traffic in secure HTTP.
Add A Comment