IIS php fastcgi and chunked request body

Jan Vávra 386 Reputation points
2025-03-18T18:19:53.47+00:00

I've found out IIS doesn't support a chunked request bodies, eg.

enter image description here

I found a mention:

In HTTP/1.1, chunked transfer encoding is primarily a server-side response mechanism. The specification (RFC 9112, previously RFC 7230 and RFC 2616) defines chunked encoding as a way for the server to send responses when the content length is unknown in advance.

However, HTTP/1.1 does allow chunked requests, but support for them is optional for servers. Many web servers, including IIS, do not support chunked request bodies, meaning they do not accept incoming requests that use chunked transfer encoding.

Anyway. In my scenario the curl never returns and still blocks a IIS/php-cgi.exe process. On a second request it starts second php fastcgi php-cgi.exe process untill a maximum configured (eg. 16).

In that case everything is blocked and no other clients like browser are served by php-cgi.

Still I can get a static content but the php application is stucked.

Why IIS doesn't respond something like HTTP 400 Bad Request etc. ?

Can I still configure IIS to accept chunked request bodies?

Jan.

Windows development | Internet Information Services
{count} votes

1 answer

Sort by: Most helpful
  1. Tom Tran (WICLOUD CORPORATION) 10 Reputation points Microsoft External Staff
    2025-06-26T08:41:18.8+00:00

    Hi @Jan Vávra,

    You're right that HTTP/1.1 allows chunked transfer encoding. However, IIS does not currently support chunked request bodies for incoming requests. When such a request is received, IIS passes it to the FastCGI handler (like php-cgi.exe), which may not handle it correctly.

    This can result in the request not completing as expected. IIS does not reject the request with a 400 error because it doesn't detect the chunked body as invalid.

    Why doesn't IIS return a 400 Bad Request?

    Because IIS doesn't detect the request. So, it doesn't know that it's supposed to reject chunked requests. It just silently passes them onto PHP, which hangs.

    Can IIS be configured to accept chunked request bodies?

    At this time, there is no built-in support in IIS for handling chunked request bodies. Configuration options are limited, especially when using PHP with FastCGI.

    Workarounds:

    1. Avoid chunked uploads by configuring the client to send a Content-Length header instead.
    2. Adjust FastCGI settings like requestTimeout and activityTimeout to reduce the impact of long-running processes. See: FastCGI settings in IIS
    3. Consider alternative platforms such as Linux with nginx or Apache if chunked uploads are required.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.