You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Ashly Pridmore <As...@juniperbridge.com> on 2013/03/04 13:11:25 UTC

[users@httpd] PHP script not executing with empty POST when using chunked encoding

Good afternoon,

We are using Apache and PHP to form a CWMP server for TR69 provisioning of customer routers. We have two bits of kit we are looking to use, two ZyXEL routers with model numbers AMG1202 and NBG1202.

To cut a long story short, we are able to communicate happily with the AMG1202, but are running into a show-stopping issue with the NBG1202. After some tracing, it seems to come down to the way that they send empty POST messages to the server (this is done to denote to the server that they are awaiting a command).

The AMG sends:

POST /{URL} HTTP/1.1
Host: {Host}
User-Agent: Allegro-Software-WebClient/4.07
Accept: */*
Content-Type: text/xml; charset=utf-8
Content-Length: 0
Cookie: PHPSESSID=sj810he8epc5hlqsautj96j1u0\r\n
\r\n

Which works fine. The script executes and returns a response.
The NBG on the other hand, sends the following:

POST /{URL} HTTP/1.1
HOST: {Host}
User-Agent: workssys.com
Transfer-Encoding: chunked
Content-Length: 0
Cookie2: $Version="1"
Cookie: PHPSESSID=l47r1bf2erk870i8n3m9sm4v65\r\n
\r\n
0\r\n
\r\n

This hangs with no reply. In a wireshark trace, I see the TCP ACK of the message, but apache does not return anything. However, if I send the same code in telnet, it works fine!

I can replicate this if I send the following:

POST /{URL} HTTP/1.1
HOST: {Host}
User-Agent: workssys.com
Transfer-Encoding: chunked
Content-Length: 0
Cookie2: $Version="1"
Cookie: PHPSESSID=l47r1bf2erk870i8n3m9sm4v65\r\n
\r\n

However the wireshark trace shows that the full packet has been received. I'm relatively confident this is an issue with the ZyXEL NBG1202 and have logged a ticket with them, but was wondering if there was anything I could do in the meantime to get Apache to accept the request (it looks like it's waiting for more input, and so isn't executing the PHP script. I'm wondering if it is possible to set a timeout on the request, say 5 seconds or so?). It's worth noting that the original message to the server goes through fine (this is a POST message that is not empty).

Any help would be much appreciated! :)

RE: [users@httpd] PHP script not executing with empty POST when using chunked encoding

Posted by Ashly Pridmore <As...@juniperbridge.com>.
For anyone interested in this, we did eventually manage to get to the bottom of the issue. The NBG4604 wasn't honoring the connection-close header and was attempting to send on a closed socket, hence it had no reply back from Apache.

The fix for this was to enable KeepAlive under the virtualhost options. Hopefully that helps someone else out there!

-----Original Message-----
From: Ashly Pridmore [mailto:Ashly.Pridmore@juniperbridge.com] 
Sent: 04 March 2013 13:20
To: users@httpd.apache.org
Subject: RE: [users@httpd] PHP script not executing with empty POST when using chunked encoding

Hi Nick,

In the PHP script (before the session is established, which I had previously thought was related to this fault) I had a line to write to a file if the page was accessed. This is not done when this error occurs, leaving me to think the PHP script is not being executed (but works fine otherwise). 

Is there a better way to find out?


-----Original Message-----
From: Nick Kew [mailto:nick@webthing.com]
Sent: 04 March 2013 13:19
To: users@httpd.apache.org
Subject: Re: [users@httpd] PHP script not executing with empty POST when using chunked encoding

On Mon, 4 Mar 2013 07:49:30 -0500
Eric Covener <co...@gmail.com> wrote:

> On Mon, Mar 4, 2013 at 7:42 AM, Ashly Pridmore 
> <As...@juniperbridge.com> wrote:
> > Hmm, so the problem is sending "content-length: 0" with "transfer-encoding" set to chunked?
> 
> The spec says T-E is ignored in this case.

The spec actually says the reverse:

4.4 Message Length
  3.  ...  If a message is received with both a
      Transfer-Encoding header field and a
      Content-Length header field, the latter
      MUST be ignored.

Perhaps the OP is seeing something (PHP?) waiting for input when it shouldn't.  Does it make any difference if you use mod_headers to inject a Connection: Close in the request and/or response?  If identical headers work fine with telnet, then it has to be something other than headers, like holding the connection.

--
Nick Kew

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


RE: [users@httpd] PHP script not executing with empty POST when using chunked encoding

Posted by Ashly Pridmore <As...@juniperbridge.com>.
Hi Nick,

In the PHP script (before the session is established, which I had previously thought was related to this fault) I had a line to write to a file if the page was accessed. This is not done when this error occurs, leaving me to think the PHP script is not being executed (but works fine otherwise). 

Is there a better way to find out?


-----Original Message-----
From: Nick Kew [mailto:nick@webthing.com] 
Sent: 04 March 2013 13:19
To: users@httpd.apache.org
Subject: Re: [users@httpd] PHP script not executing with empty POST when using chunked encoding

On Mon, 4 Mar 2013 07:49:30 -0500
Eric Covener <co...@gmail.com> wrote:

> On Mon, Mar 4, 2013 at 7:42 AM, Ashly Pridmore 
> <As...@juniperbridge.com> wrote:
> > Hmm, so the problem is sending "content-length: 0" with "transfer-encoding" set to chunked?
> 
> The spec says T-E is ignored in this case.

The spec actually says the reverse:

4.4 Message Length
  3.  ...  If a message is received with both a
      Transfer-Encoding header field and a
      Content-Length header field, the latter
      MUST be ignored.

Perhaps the OP is seeing something (PHP?) waiting for input when it shouldn't.  Does it make any difference if you use mod_headers to inject a Connection: Close in the request and/or response?  If identical headers work fine with telnet, then it has to be something other than headers, like holding the connection.

--
Nick Kew

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] PHP script not executing with empty POST when using chunked encoding

Posted by Nick Kew <ni...@webthing.com>.
On Mon, 4 Mar 2013 07:49:30 -0500
Eric Covener <co...@gmail.com> wrote:

> On Mon, Mar 4, 2013 at 7:42 AM, Ashly Pridmore
> <As...@juniperbridge.com> wrote:
> > Hmm, so the problem is sending "content-length: 0" with "transfer-encoding" set to chunked?
> 
> The spec says T-E is ignored in this case.

The spec actually says the reverse:

4.4 Message Length
  3.  ...  If a message is received with both a
      Transfer-Encoding header field and a
      Content-Length header field, the latter
      MUST be ignored.

Perhaps the OP is seeing something (PHP?) waiting for
input when it shouldn't.  Does it make any difference
if you use mod_headers to inject a Connection: Close
in the request and/or response?  If identical headers
work fine with telnet, then it has to be something other
than headers, like holding the connection.

-- 
Nick Kew

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] PHP script not executing with empty POST when using chunked encoding

Posted by Eric Covener <co...@gmail.com>.
On Mon, Mar 4, 2013 at 7:42 AM, Ashly Pridmore
<As...@juniperbridge.com> wrote:
> Hmm, so the problem is sending "content-length: 0" with "transfer-encoding" set to chunked?

The spec says T-E is ignored in this case.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


RE: [users@httpd] PHP script not executing with empty POST when using chunked encoding

Posted by Ashly Pridmore <As...@juniperbridge.com>.
Hmm, so the problem is sending "content-length: 0" with "transfer-encoding" set to chunked?

I just find it odd that sending it through telnet works fine, this should be the exact same as the code the ZyXEL is sending.

-----Original Message-----
From: Jens-U. Mozdzen [mailto:jmozdzen@nde.ag] 
Sent: 04 March 2013 12:27
To: users@httpd.apache.org
Subject: Re: [users@httpd] PHP script not executing with empty POST when using chunked encoding

Hi Ashley,

Zitat von Ashly Pridmore <As...@juniperbridge.com>:
> [...]
> The NBG on the other hand, sends the following:
>
> POST /{URL} HTTP/1.1
> HOST: {Host}
> User-Agent: workssys.com
> Transfer-Encoding: chunked
> Content-Length: 0
> Cookie2: $Version="1"
> Cookie: PHPSESSID=l47r1bf2erk870i8n3m9sm4v65\r\n
> \r\n
> 0\r\n
> \r\n

What might be confusing the server is that the content actually isn't empty, although Content-Length is set to 0.

Regards,
Jens


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org

Re: [users@httpd] PHP script not executing with empty POST when using chunked encoding

Posted by "Jens-U. Mozdzen" <jm...@nde.ag>.
Hi Ashley,

Zitat von Ashly Pridmore <As...@juniperbridge.com>:
> [...]
> The NBG on the other hand, sends the following:
>
> POST /{URL} HTTP/1.1
> HOST: {Host}
> User-Agent: workssys.com
> Transfer-Encoding: chunked
> Content-Length: 0
> Cookie2: $Version="1"
> Cookie: PHPSESSID=l47r1bf2erk870i8n3m9sm4v65\r\n
> \r\n
> 0\r\n
> \r\n

What might be confusing the server is that the content actually isn't  
empty, although Content-Length is set to 0.

Regards,
Jens


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org