I suppose it goes without saying that I'm baffled by the following. This is a faux-continuation of my queries here: HTTP 303 (SeeOther): GET Works, POST Fails I'm posting another question because the other deals primarily with HTTP redirections, and does not address what I now believe to be the underlying problem.
I have a very simple web.py class:
class user:
def GET(self, id):
"""List a single user"""
web.header('Cache-control', 'no-cache')
return 'wtf!!'
def POST(self, id):
"""Save an updated user"""
web.header('Cache-control', 'no-cache')
return 'wtf!!'
If I GET from this resource, I receive my stupid-simple 'wtf!!' text in response.
If I POST to this resource, I get mixed results depending on the source of the request.
- Google Chrome: Completely fails. Using the developer tools network analyzer, I can see the request go out. After ~15 seconds, it says that it failed.
- IE9: Technically, it works. After waiting for ~15 seconds, the expected response will always arrive.
- PuTTY/Telnet: Works perfectly. The response appears near-instantaneously, as expected.
Thinking that perhaps the web browsers were adding some headers that broke web.py, I decided to open up Wireshark to investigate. I found that the responses were always received by the client in a timely manner. However, I did notice that Wireshark was not recognizing the responses to a POST request as HTTP (which is something it would do for the responses to a GET request).
EDIT: I've been working on testing/troubleshooting this and I have more developments.
The GET and POST responses are both coming back to the client with the header 'Transfer-encoding: chunked'. This means that rather than sending the whole page, it will send bits and pieces as they're ready. The general format is:
200 OK, etc
{Headers}
5 # Num. of Chars in This Chunk (in hex)
Hello
200 OK, etc
{Headers}
0 # Signifies no more chunks to come
I use Wireshark to look for these packets. I'm noticing that the GET response looks like it should, but the POST response seems to be missing that last chunk. As a result, the connection stays open until it times out (since it expects more data to come from the server).
Here are things that are touching the request on the server side. I'm not sure which one is responsible for 'chunking' the data.
- Apache
- mod_cgi
- flup
- web.py
- my app
My questions now:
Which component actually 'chunks' my request?
Why is it failing to send the last chunk (only for POST responses)?