IIS7 refuses to download encoding files

I have a Windows / Apache2 / PHP application that receives a file using encoded encoding. The reason is that the downloaded file is dynamic and its length is unknown before transfer. It always worked great.

Now I need to port the application to IIS7 / PHP. The problem is that IIS cannot get the chunked file: when the file is downloaded, the server simply does not respond at all. How to solve this?

Please note that in my test I do not even use PHP. I just have the .php extension because IIS refuses POST in the .htm file (which makes sense).

As rupello suggested in this answer , I checked cURL to make sure my client is not broken. cURL also cannot get a response, although everything works fine if the transfer fails.

I did the following tests:

test.php:

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf8" />
  </head>
  <body>
    <form method="post" enctype="multipart/form-data">
      File: <input type="file" name="upfile" />
      <input type="submit" value="go"/>
  </form>
  </body>
</html>

This command does not return (stuck waiting for a response)

curl.exe http://serveur/test.php --form "upfile=@text.txt" 
   -H "Transfer-Encoding: chunked" -H "Expect:"

Note: -H "Expect:"is the suppression Expect 100-Continueissued by curl. The result is the same without this header, and, of course, an additional circuit. Sent:

POST http://serveur/test.php HTTP/1.1
User-Agent: curl/7.15.3 (i586-pc-mingw32msvc) libcurl/7.15.3 zlib/1.2.2
Host: serveur
Pragma: no-cache
Accept: */*
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: multipart/form-data; boundary=----------------------------310dbcc6761b

8c
------------------------------310dbcc6761b
Content-Disposition: form-data; name="upfile"; filename="text.txt"
Content-Type: text/plain


5
hello
30

------------------------------310dbcc6761b--

0

Problem: nothing is returned by the server. The server looks like it is waiting. the curl does not return.

The same command without chunk encoding works as expected:

Sent:

POST http://serveur/test.php HTTP/1.1
User-Agent: curl/7.15.3 (i586-pc-mingw32msvc) libcurl/7.15.3 zlib/1.2.2
Host: serveur
Pragma: no-cache
Accept: */*
Connection: Keep-Alive
Content-Length: 193
Content-Type: multipart/form-data; boundary=----------------------------e2d761bc173a

------------------------------e2d761bc173a
Content-Disposition: form-data; name="upfile"; filename="text.txt"
Content-Type: text/plain

hello
------------------------------e2d761bc173a--

Now the server responds correctly:

HTTP/1.1 200 OK
Content-Type: text/html
Server: Microsoft-IIS/7.5
X-Powered-By: PHP/5.3.8
X-Powered-By: ASP.NET
Date: Mon, 21 Nov 2011 10:47:57 GMT
Content-Length: 272

<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf8" />
</head>
<body>
  <form method="post" enctype="multipart/form-data">
    File: <input type="file" name="upfile" />
    <input type="submit" value="go"/>
  </form>
</body>
</html>

Testing on a LAMP server with the same files and requests works fine.

So, how do I enable request encoding on IIS?

. ASP, :

C:\...\inetsrv>appcmd.exe set config /section:asp /enableChunkedEncoding:True
Applied configuration changes to section "system.webServer/asp" for "MACHINE/
WEBROOT/APPHOST" at configuration commit path "MACHINE/WEBROOT/APPHOST"
+5
2

HTTP 1.1 spec, - , (Wiki ). , , IIS.

, , APACHE , HTTP.

0

IIS 7 ( , IIS 7.5) chuncked. IIS Http 400: . (,

5 
hello 

5
h ello 

CGI IIS PHP. IIS, , , PHP () CGI . . PHP-Bugs ID 60826

+3

All Articles