HTTP Requests rely upon three required parts and one optional fourth part:

  • The URL (or URI) – This is the name, address, or location of the machine that is listening for HTTP requests to come in. Typically this is a web server and is referenced by its canonical URL (e.g., www.mywebsite.com). Additional information appended to this URL might also be present which serves to define the request in greater detail. Obviously the URL is always required.

  • HTTP Method (aka Verb) – Clients use HTTP methods to notify the server what it is expecting the request to do. HTTP methods do not impose their own rules but rather assume the server will respond appropriately. Common methods are GET, POST, PUT, and DELETE, but there are others as well. Proper interpretation and handling of HTTP methods can be reviewed through various online resources but here is a summary: GET expects the server to return the resource associated to the URL (which can either be a static resource or one that is dynamically generated via a program.) POST expects to create a new resource on the server using the content of the body (see below). PUT expects to update an existing resource, also using the body. DELETE expects to remove an existing resource. In some ways HTTP methods correspond to CRUD, but it would be a disservice to draw too close of a comparison. The HTTP method is always required. URLs entered into a web browser are implicitly passed along with the GET method. The other methods are usually specified within programming languages like JavaScript.

  • Header Fields – Each HTTP request comes with one or more name/value pairs known as header fields. In most cases these will be standard fields but there are occasions when custom fields can be used. Header fields are used to notify the server of useful information such as the format of the body, authentication credentials, and formats that it can accept in the response. Server-side programs (like Basic+ routines called by the OECGI) can view these header fields and their values and respond accordingly. There is always at least one header field.

  • Body – Some HTTP methods, such as POST and PUT, need to provide the server with information necessary to fulfill the purpose of the request. The body is where this content can be contained. For instance, if a new customer needs to be created on the server then the client can put the relevant customer data into the body. This is usually in some standard format such as XML or JSON. The body is never required although there is not much a server can do with a POST or PUT method without information to work with. The GET and DELETE methods do not use the body.
  • No labels