There are two types of HTTP messages, requests and responses, each with its own format.
Requests consist of the following elements:
- An HTTP method, usually a verb like GET, POST, or a noun like OPTIONS or HEAD that defines the operation the client wants to perform. Typically, a client wants to fetch a resource (using GET) or post the value of an HTML form (using POST), though more operations may be needed in other cases.
- The path of the resource to fetch; the URL of the resource stripped from elements that are obvious from the context, for example without the protocol (http://), the domain (here, developer.mozilla.org), or the TCP port (here, 80).
- The version of the HTTP protocol.
- Optional headers that convey additional information for the servers.
- A body, for some methods like POST, similar to those in responses, which contain the resource sent.

Responses consist of the following elements:
- The version of the HTTP protocol they follow.
- A status code, indicating if the request was successful or not, and why.
- A status message, a non-authoritative short description of the status code.
- HTTP headers, like those for requests.
- Optionally, a body containing the fetched resource.

|
Short Description |
 |
Returns HTTP request received. |
 |
Returns method of the request (GET, PUT, POST, etc). |
 |
Returns the path of the resource to fetch. |
 |
Returns settings of the headers for the request. |
 |
Returns body contents that have been added to the request. |
 |
Returns the size of the message body, in bytes, sent to the recipient. |
 |
creates a new Response object defining a body for the response. |
 |
returns a pointer to the end of the headers in the request. |
For descriptions of the blocks below, please refer to the Requests and Responses items above.

This block returns the HTTP request sent from the client.
Normally, the returned information is captured in a variable and that variable is used to parse out the different parts of the request using the libraray blocks below.
The optional field of this block allows capturing binary data.



¶ body of request



This block is used to formulate the server response to be sent out, including a status code, status message, and response body.

Returns a pointer to the end of the headers in the request.
Download Link: HTTP Server Enhanced
The MicroBlocks IDE includes a simple HTTP Server program example. There is a slightly enhanced version of that program provided here, where the various Request parts are individually displayed, for better comprehension by the user.
To achieve that, we created a requestSave variable to capture the incoming request, so we can display the various parts of it.
After the browser inquiry is submitted, the server saves the incoming inquiry into the new requestSave variable. We then show the various request parts in the pictures below.




