Simple Case (Small Amount of Variable Data)
|Top Previous Next|
In most cases the client will send a fairly small amount of variable data, so it all will fit in 255 bytes. Use the sock.httprqstring R/O property, as shown in the following example. Say, you have a login to perform. The user enters his/her name and password on page "index.html". Actual login is processed on page "login.html". The data is passed between these two pages "invisibly", using the HTTP POST method.
Here is the file "index.html":
And here is "login.html":
The advantage of using the sock.httprqstring is that the variable data is always there, no matter how many times you read it. Be forewarned, though...
Let's talk a bit about why the socket may get stuck. The following diagram details the flow of HTTP request and response processing:
As you can see from the diagram, the socket will automatically extract the variable data and store it into the VAR buffer. The code example above will access the buffer during the reply phase — from within the "login.html" page. Problem is, processing may never get that far. If the VAR buffer becomes full in the request processing phase, the socket will simply keep waiting, and the reply phase will never start! This is true no matter what HTTP method you use — GET or POST. Read on and we will tell you how to avoid this.