Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. XMLHttpRequest POST message flow.

XMLHttpRequest POST message flow.

Scheduled Pinned Locked Moved C / C++ / MFC
comsysadminhardwaretestingbeta-testing
7 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Neville Franks
    wrote on last edited by
    #1

    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

    L 1 Reply Last reply
    0
    • N Neville Franks

      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

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      Neville Franks wrote:

      It appears

      Appears? :confused:

      led mike

      N 1 Reply Last reply
      0
      • L led mike

        Neville Franks wrote:

        It appears

        Appears? :confused:

        led mike

        N Offline
        N Offline
        Neville Franks
        wrote on last edited by
        #3

        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

        L 1 Reply Last reply
        0
        • N Neville Franks

          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

          L Offline
          L Offline
          led mike
          wrote on last edited by
          #4

          Verb: appear: also "It appears you still have not explained how you determined this is happening" :laugh:

          led mike

          N 1 Reply Last reply
          0
          • L led mike

            Verb: appear: also "It appears you still have not explained how you determined this is happening" :laugh:

            led mike

            N Offline
            N Offline
            Neville Franks
            wrote on last edited by
            #5

            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

            L 1 Reply Last reply
            0
            • N Neville Franks

              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

              L Offline
              L Offline
              led mike
              wrote on last edited by
              #6

              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

              N 1 Reply Last reply
              0
              • L 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

                N Offline
                N Offline
                Neville Franks
                wrote on last edited by
                #7

                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

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups