soap-response: is Content-Length required in http-header?

lighttpd, php, soap

Solution

First question No, as the HTTP 1.1 spec doesn't require the `Content-Length` header and SOAP is built on top of HTTP. It's possible that your SOAP client requires it, but SOAP itself doesn't. (The SOAP spec doesn't even contain the word "length")

Second question PHP is probably wrong there. It shouldn't be setting a `Content-Length` header. lighttpd is probably also a bit wrong, as it should really override the `Content-Length` header if it changes the content. And soapUI could correct for the issue, as SOAP is based on XML which has a very clear EOF (the closing tag).

I recommend not letting PHP set a `Content-Length` header.

Problem

I didn't found a answer to this in w3.org. Almost all examples include the content length in the soap-response http-header. first Q: But is it technically necessary? i am struggling with an soap-service where the php-soap-library (PEAR SOAP_Server) is setting the right content length of the response xml, but lighttpd afterwards is compressing the content, and so i am getting a smaller response than the content length. And some applications like soapUI is waiting for alle the content (set by the http-header) to arrive. second Q: - Who is behaving/configured wrong in this chain? php -> lighttpd -> soapUI - is it the php-code which sets the unzipped content-length? - is it lighttpd which compresses the response, but doesn't override or delete the content-length header? - Or is it soapUI, which shouldn't wait 15sec for further content? EDIT: Further investigation revealed, that the php-script is compressing the content itself and is setting always the umcompressed Content-length, not lighttpd. Nevertheless Tom van der Woerdts answer is very helpfull.

Original source