The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

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.
Neville Franks Send private email
Wednesday, February 06, 2008
 
 
Hi Neville --

I also wrote a small embedded HTTP server.  HTTP POST is as you said: headers, a blank line, and then content.  That's how I coded mine and it works with WinInet and WinHTTP (those are the only technologies that I've used to POST with -- haven't posted with a browser).

Let me know if you'd like to compare notes (and from a post from _way_ back, I never have added OpenSSL yet--still on the TODO list).
Doug Send private email
Wednesday, February 06, 2008
 
 
Should have read the post a little closer: I AM handling XMLHttpRequests from within a browser, and I see what you expect (ie one big data transfer, not an OK sent back in the middle)
Doug Send private email
Wednesday, February 06, 2008
 
 
>Should have read the post a little closer: I AM handling XMLHttpRequests from within a browser, and I see what you expect (ie one big data transfer, not an OK sent back in the middle)

Doug, thanks for that. So far I've only tested this with IE6. What Browser(s) did you try.

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 Send private email
Wednesday, February 06, 2008
 
 
I am just guessing here, but because XMLHttpRequest is mainly  used with AJAX, could be that it is not following the exact rules as for regular HTTP post. I also saw on wikipedia that IE6 and IE7 has it implemented differently.

On the other hand, I know from practice that on the client side you can get first just the headers and then the body. Until recent I believed that they must either all come together or the transfer should be set as chunked.
Goran Burcevski Send private email
Wednesday, February 06, 2008
 
 
I tried IE 7 and FireFox 2.  I'm quite certain it comes in a single incoming transfer because of my understanding of the spec, but much more importantly, my code wouldn't handle an OK in the middle :)
Doug
Wednesday, February 06, 2008
 
 
>... HTTP 1.1 RFC etc. Which indicates the
>POST Headers and Body are sent as one.

Correct, as far as it goes.  Yes, header and body are sent as one stream.

However, TCP/IP can (and often will) fragment the message so that multiple packets are sent.  It is up to the receiver to continue reading until all packets are received.  Indeed, that is why there is a body byte count in the header.

There are other possibilities here (i.e. a HEAD being sent) that could account for what you are seeing.
Dennis Reinhardt Send private email
Wednesday, February 06, 2008
 
 
Thanks all. I'm pretty sure I know what the problem is. The server stopped when it received the headers as until now it only handled HTTP GET.

With POST it has to keep receiving packets until the BODY is received.

And yes it appears as though the Header is received in one packet and the Body in following packet(s).

I'm using WSARecv not the higher level WinInet stuff.
Neville Franks Send private email
Wednesday, February 06, 2008
 
 
> I'm working on a small embedded web server for my app
> Surfulater

Hmmmmm... peer-to-peer document serving over the internet? Seems like a waste of effort. Why not just host the user data on your own internet servers? Care to discuss your rationale?
coder
Thursday, February 07, 2008
 
 
>Hmmmmm... peer-to-peer document serving over the internet?

I don't know how you came to this conclusion but it is way off track. The embedded server serves up content to the app.
Neville Franks Send private email
Thursday, February 07, 2008
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz