1.5 HTTP Methods
The role of the method in the request line is to specify what “action” the client [i.e. the browser] has requested. Now on to the most common methods you will typically use in web dev.
The GET method is the most commonly used in apis and websites. It is used to request information from a specified URL. For example:
The POST method is used to update an existing resource. This method will request that the server accept the data enclosed within the body of the request message
The PUT method will request the server to store the contents of the request body at the specified URL. For example:
PUT/hello.html HTTP/1.1 User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT) Host: www.kauress.me Accept-Language: en-us Connection: Keep-Alive Content-type: text/html Content-Length: 180
The above HTML will be PUT at the specified resource hello.html
The delete method is used to delete a resource at a specified location. For example:
DELETE /hello.html HTTP/1.1 User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT) Host: www.kauress.me Accept-Language: en-us Connection: Keep-Alive Content-type: text/html Content-Length: 180 In the above example, the file hello.html is deleted.
1.9 Response Status Codes
When a request message comes to a server by a browser, the server will interpret the message and carry out whatever action needs to be taken depending on the method used. After which the server sends a response message back to browser.