Skip to main content

HTTP & HTTP request

HTTP (Hypertext Transfer Protocol)

HTTP is a protocol for fetching resources such as HTML documents. It is the foundation of any data exchange on the Web, and it is a client-server protocol. In HTTP there are four methods that are commonly used in a REST-based Architecture i.e., POST, GET, PUT, and DELETE. These correspond to create, read, update, and delete or CRUD operations respectively.

http-2048x1107.jpg

HTTP request

GET: The HTTP GET method is used to read (or retrieve) a representation of a resource.

  • HTTP response code of 200 (OK). 
  • HTTP response error case, it most often returns a 404 (NOT FOUND) or 400 (BAD REQUEST).

POST: The POST verb is most often utilized to create new resources. In particular, it’s used to create subordinate resources.

  • HTTP response code of 201 (On successful creation) and a Location header with a link to the newly created resource with the 201 HTTP status. 

PUT: It is used for updating the capabilities. However, PUT can also be used to create a resource in the case where PUT is go to a URI that contains the value of a non-existent resource ID. 

  • HTTP response code of 200 (OK) or 204 if not returning any content in the body from a PUT.
  • If using PUT for create HTTP response code of 201 (On successful creation) same as POST

DELETE: It is used to delete a resource identified by a URI.

  • HTTP response code of 200 (OK) along with a response body.

Example of HTTP with params

what-are-url-parameters12172022.jpg

When the HTTP method is used to request certain resources from the web server, the client also sends some parameters to the web server. To determine the URL parameter, we look at the part of the URL after the question mark (?). URL Parameters are created with a key and a value {key=value}, separated by an equal sign (=). Multiple parameters are then separated by an ampersand (&).

http param.JPG

with this http and param this is the result from facebook:

program meme.JPG