The HTTP request object

The request object contains the following fields:


The low-level socket used for communicating with the HTTP server. May be nil if the connection has been closed.


A slightly higher-level connection object, usually you will want to interact with this rather than conn.


A simple function to write data to the request's underlying connection.

The HTTP server's hostname parsed from the URL passed to http.request().


The port used to connect to the HTTP server. Automatically parsed from the URL passed to http.request().


The path to the file to request from the HTTP server, automatically parsed from the URL passed to http.request().


The query part of the URL passed to http.request(). That is, any part of the URL after the '?' character appears in the path.


The caller set options.onlystatus to indicate that they are only interested in the status code of this request.


The method used by this request. Note! For efficiency the method always has a space after it. eg. "GET " and "POST ". Removing this space will cause requests to be rejected by the HTTP server.


The callback for the request, as passed to http.request().


An object which receives the raw data from the HTTP server, parses it, and is responsible for calling the callback when the full response is received.


An internal state variable recording what "mode" the request reader is in.


A flag set to true if the request has been destroyed. Callbacks will no longer be called for this request. Don't set this flag manually… use http.destroy_request() if you must (it is usually done for you).


An array of strings, which when joined comprise the total response body received from the server so far.


The anticipated response body length, when complete. As seen in the Content-Length header. May be nil if the server did not specify a Content-Length.


The current length of the received body part of the HTTP response.


A table of the headers received in the HTTP response from the server. All keys are lower-cased, eg. request.responseheaders["content-length"].


The HTTP status code received from the server. A number, not a string.


The HTTP version given by the server in its response. Usually "1.0" or "1.1". A string, not a number.