tdedecko
tdedecko

Reputation: 1482

HTTP POST Requests require multiple transmissions?

I found the quoted text in Programming Python 3rd edition by Mark Lutz from Chapter 16: Server-Side Scripting (page 987):

Forms also include a method option to specify the encoding style to be used to send data over a socket to the target server machine. Here, we use the post style, which contacts the server and then ships it a stream of user input data in a separate transmission. An alternative get style ships input information to the server in a single transmission step, by adding user inputs to the end of the URL used to invoke the script, usually after a ? character (more on this soon).

I read this with some puzzlement. As far as I know post data is sent in the same transmission as a part of the same http header. I have never heard of this extra step for post data transmission.

I quickly looked over the relevant HTTP rfc's and didn't notice any distinction in version 1.0 or 1.1. I also used wireshark for some analysis and didn't notice multiple transmissions for post.

Am I missing something fundamental or is this an error in the text?

Upvotes: 2

Views: 393

Answers (3)

Brian Low
Brian Low

Reputation: 11811

The HTTP Expect 100-Continue header (see 8.2.3) and 100 Continue response allows the client split HTTP POSTs into 2 transmissions (over a single connection):

The purpose of the 100 (Continue) status is to allow a client that is sending a request message with a request body to determine if the origin server is willing to accept the request (based on the request headers) before the client sends the request body.

In some cases, it might either be inappropriate or highly inefficient for the client to send the body if the server will reject the message without looking at the body.

I don't think most browsers use this but some libraries/utities do (curl, .Net).

Upvotes: 0

tdedecko
tdedecko

Reputation: 1482

Yes, there is only one transmission of data between server and client.

The context of the passage was referring to communication between web server and cgi application. Server communication between the web server and the cgi application using POST happens in two separate transfers. The request for the python script is sent by the server in a single transfer and then the POST data is sent separately over stdin (two transfers).

Whereas with GET the input data is passed as env vars or command line args in one transfer.

Upvotes: 0

Adeel
Adeel

Reputation: 19228

Simple POST request is in single step. but when you are uploading a file, than the form is posted in multiple parts. In that case, the content type application/x-www-form-urlencoded is changed to multipart/form-data.

Upvotes: 1

Related Questions