DEV Community

Clairehou111
Clairehou111

Posted on • Edited on

An overview of http

The page document

click the link godaddy website, open the devloper Tool by press CTR+F12.

resources it requested

resources it requested

Refresh this page. you will see all the resources the exploer has requested. The page you are seeing is a html document , which is reconstructed from different resources, such as layout(the .css file),images ,js, videos and some other format resources.

request and response.

request and response brief

  1. It's the program(client) on behalf of a user to initiate a request, such as web browers and other tools programmers used like curl. The client initiate the TCP connection, after network connection was estabilished,it send the request.

  2. Server serve the document as reqeusted. it appears as only a single machine ,but it may actually be a collection of machines.

share the load, other software instances like cache,db servers.

  1. proxies between client and server.

http request header

request uri

http request and response massage format

       Full-Request   = Request-Line              ; 
                        *( General-Header         ; 
                         | Request-Header         ; 
                         | Entity-Header )        ; 
                        CRLF
                        [ Entity-Body ]           ; 
Enter fullscreen mode Exit fullscreen mode

Request-Line = Method SP Request-URI SP HTTP-Version CRLF

A exmaple of request message

request message

       Full-Response  = Status-Line               
                        *( General-Header         
                         | Response-Header        
                         | Entity-Header )        
                        CRLF
                        [ Entity-Body ]           
Enter fullscreen mode Exit fullscreen mode

Status-Line = HTTP-Version SP Status-Code SP Reason-Phrase CRLF

A exmaple of response message

response message

user-agent

http method

  • GET should only retrieve data
  • POST submit a form to the server, cause a change or effect to the resource.
  • PUT create a resource
  • DELETE delete a resource
  • HEAD identical to GET except the server does not return message body in the response.
  • OPTIONS
    check the methods of the resource supported, work together
    with http header Allow

  • PATCH

status code

Informational responses (100 – 199)
Successful responses (200 – 299)
Redirection messages (300 – 399)
Client error responses (400 – 499)
Server error responses (500 – 599)

The frequently used status codes

  • 200 OK the server handled the request successfuly.
  • 301 moved Permanently the resource was moved. work with the response header location
  • 307 Temporary Redirect work with the response header location

classic usage:short url <
classic usage:short url

  • 308 Permanent Redirect work with the response header location
  • 400 Bad Request
  • 401 Unauthorized no valid sign
  • 404 not found no resource specified in the request
  • 405 method not allowed the resource does not support the request method
  • 500 Internal Server Error the remaining server side error can't fall to other categroy. 502 bad gateway gateway error or gateway receives invalid response from the origion server. 503 Service Unavailable the server is down for maintance or overloaded. Might return retry-after in response header. 504 gateway timeout gateway doesnt get the response from origion server in limited time or even not able to connect the origion server.

HTTP Headers

  • accept
  • content-type
  • content-length

connection-alive

stateless

Top comments (0)