Details on Variable Data
So far, we haven't touched on the subject of actual data that you will read using sock.httprqstring and sock.gethttprqstring. In other words, we haven't discussed the contents of the VAR buffer. It is time to clear this.
We have already explained that sock.httprqstring and sock.gethttprqstring will return the same data, with the only difference that the sock.httprqstring will not actually remove the data from the VAR buffer and will not be able to access past the first 255 bytes of such data.
The data format in the VAR buffer depends on the method used.
VAR Buffer Contents — HTTP GET Method
Suppose the client has sent the following request:
GET /form_get.html?user=CHUCKY&pwd=THEEVILDOLL HTTP/1.1
Host: 127.0.0.1:1000
User-Agent: Mozilla/5.0 (and so on)
The VAR buffer will get everything past the URL and until the first CR/LF. That part is highlighted in blue. There are two variables — user and pwd. They are equal to "CHUCKY" and "THEEVILDOLL" respectively. Your application can just ignore the "HTTP/1.1" part.
VAR Buffer Contents — HTTP POST Method
Here is a sample client request:
POST /form_get.html HTTP/1.1
Host: 127.0.0.1:1000
User-Agent: Mozilla/5.0
(lots of stuff skipped)
Content-Type: multipart/form-data; boundary=---------------------------21724139663430
Content-Length: 257
-----------------------------21724139663430
Content-Disposition: form-data; name="user"
CHUCKY
-----------------------------21724139663430
Content-Disposition: form-data; name="pwd"
THEEVILDOLL
-----------------------------21724139663430--
You will get everything shown in blue.