XMLHttpRequest POST message flow.
-
I'm working on a small embedded web server for my app Surfulater and wonder if anyone knows the steps involved in a XMLHttpRequest POST. It appears that the server gets the Headers first, then sends back a 200 OK response and then receives the BODY for the POST. This isn't my understanding of how it should work from reading the HTTP 1.1 RFC etc. Which indicates the POST Headers and Body are sent as one. My testing so far has been from IE6 only. I'm trying to work out if my code is wrong or my understanding of the HTTP spec or the Browser implementation varies.
Neville Franks, Author of Surfulater www.surfulater.com "Save what you Surf" and ED for Windows www.getsoft.com
-
I'm working on a small embedded web server for my app Surfulater and wonder if anyone knows the steps involved in a XMLHttpRequest POST. It appears that the server gets the Headers first, then sends back a 200 OK response and then receives the BODY for the POST. This isn't my understanding of how it should work from reading the HTTP 1.1 RFC etc. Which indicates the POST Headers and Body are sent as one. My testing so far has been from IE6 only. I'm trying to work out if my code is wrong or my understanding of the HTTP spec or the Browser implementation varies.
Neville Franks, Author of Surfulater www.surfulater.com "Save what you Surf" and ED for Windows www.getsoft.com
-
led mike wrote:
Appears
Verb: appear: 1. Give a certain impression or have a certain outward aspect "This appears to be a very difficult problem"; "They appeared like people who had not eaten or slept for a long time" 2...
Neville Franks, Author of Surfulater www.surfulater.com "Save what you Surf" and ED for Windows www.getsoft.com
-
led mike wrote:
Appears
Verb: appear: 1. Give a certain impression or have a certain outward aspect "This appears to be a very difficult problem"; "They appeared like people who had not eaten or slept for a long time" 2...
Neville Franks, Author of Surfulater www.surfulater.com "Save what you Surf" and ED for Windows www.getsoft.com
-
Verb: appear: also "It appears you still have not explained how you determined this is happening" :laugh:
led mike
led mike wrote:
also "It appears you still have not explained how you determined this is happening"
By looking at what WSARecv received. The problem was the HTTP POST data was being received in multiple TCP packets, whereas I incorrectly assumed the Header & Body would come as one.
Neville Franks, Author of Surfulater www.surfulater.com "Save what you Surf" and ED for Windows www.getsoft.com
-
led mike wrote:
also "It appears you still have not explained how you determined this is happening"
By looking at what WSARecv received. The problem was the HTTP POST data was being received in multiple TCP packets, whereas I incorrectly assumed the Header & Body would come as one.
Neville Franks, Author of Surfulater www.surfulater.com "Save what you Surf" and ED for Windows www.getsoft.com
Neville Franks wrote:
By looking at what WSARecv received. The problem was the HTTP POST data was being received in multiple TCP packets, whereas I incorrectly assumed the Header & Body would come as one.
Yes, that is an artifact of TCP not HTTP. However your original post said:
Neville Franks wrote:
It appears that the server gets the Headers first, then sends back a 200 OK response and then receives the BODY for the POST.
How do you know that? What do you mean "the server"? If it's your server, the one you are developing then you are doing it wrong. Of course the client doesn't know that because by the time it gets your 200 reply it has already sent it's entire message so it has no way of knowing that didn't read it all before you sent your reply.
led mike
-
Neville Franks wrote:
By looking at what WSARecv received. The problem was the HTTP POST data was being received in multiple TCP packets, whereas I incorrectly assumed the Header & Body would come as one.
Yes, that is an artifact of TCP not HTTP. However your original post said:
Neville Franks wrote:
It appears that the server gets the Headers first, then sends back a 200 OK response and then receives the BODY for the POST.
How do you know that? What do you mean "the server"? If it's your server, the one you are developing then you are doing it wrong. Of course the client doesn't know that because by the time it gets your 200 reply it has already sent it's entire message so it has no way of knowing that didn't read it all before you sent your reply.
led mike
You are right, the code in my server was wrong. Up until now it only had code to handle a GET and this incorrectly handled POST. It got a packet with the "complete" headers which for a GET is the end of the story. For a POST there maybe a BODY still to come. It was simply a matter of updating the logic to correctly determine the end of the POST request.
Neville Franks, Author of Surfulater www.surfulater.com "Save what you Surf" and ED for Windows www.getsoft.com