HTTP request types

Although GET requests are the most common, there are, perhaps, three request types that are commonly used. The three common HTTP request types are as follows:

  • GET is used when the client wants to download a resource.
  • HEAD is just like GET, except that the client only wants information about the resource instead of the resource itself. For example, if the client only wants to know the size of a hosted file, it could send a HEAD request.
  • POST is used when the client needs to send information to the server. Your web browser typically uses a POST request when you submit an online form, for example. A POST request will typically cause a web server to change its state somehow. A web server could send an email, update a database, or change a file in response to a POST request.

In addition to GET, HEAD, and POST, there are a few more HTTP request types that are rarely used. They are as follows:

  • PUT is used to send a document to the web server. PUT is not commonly used. POST is almost universally used to change the web server state.
  • DELETE is used to request that the web server should delete a document or resource. Again, in practice, DELETE is rarely used. POST is commonly used to communicate web server updates of all types.
  • TRACE is used to request diagnostic information from web proxies. Most web requests don't go through a proxy, and many web proxies don't fully support TRACE. Therefore, it's rare to need to use TRACE.
  • CONNECT is sometimes used to initiate an HTTP connection through a proxy server.
  • OPTIONS is used to ask which HTTP request types are supported by the server for a given resource. A typical web server that implements OPTIONS may respond with something similar to Allow: OPTIONS, GET, HEAD, POST. Many common web servers don't support OPTIONS.

If you send a request that the web server doesn't support, then the server should respond with a 400 Bad Request code.

Now that we've seen the types of HTTP requests, let's look at the request format in more detail.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.224.31.50