HTTP Overview

There are so many clients and servers that exist on the world wide web. Today they are all connected together in a network which is called the WWW network. They are connected with wires or wireless devices such as the WIFI route.

When you use your client such as iPhone to browse a page on the web. Your safari browser will send a request to the HTTP web server. After the HTTP web server receives your request, it will call the back-end program to perform business logic and then return the result back to your client. Then your client (safari browser) will render the response data to you on the iPhone screen. This is just an example process of client-server interaction mode.

web-client-server-request-response-process-architecture

1. HTTP Overview.

  1. HTTP is the abbreviation of Hypertext Transfer Protocol.
  2. It is used for web clients and servers to communicate.
  3. It is stateless that means it does not maintain the communication state between the client and server.
  4. The client sends the request and the server responds to the client, after that the connection is disconnected.
  5. If the client request again, the server will not remember that the client has done this before. Then the server will treat the request from the same client as a new one.
  6. The advantage of this design is that the server can serve more clients at the same time.

2. HTTP Methods.

  1. A client can use a number of methods to make the HTTP request.
  2. Each of these methods will let the server perform a special action. The below table will list the HTTP methods and their purpose.
  3. GET: Request to get the specified URL’s data from the HTTP server. The URL can be a static resource such as an Html page, javascript, CSS, and images, It also can be a dynamic web application such as a servlet or JSP page.
  4. POST: Ask the server to receive the data posted by the client. We always use the Html form to post data to the server.
  5. PUT: Just like the POST method, you can also use PUT to post data to the server. But the difference is that the PUT method can not only post data but also update the data posted before. With the PUT method, you can replace all existing data using the updated content.
  6. CONNECT: This is a reserve method. It is used to tell the server to create a tunnel between the client and the server.
  7. DELETE: Tell the server to delete some web resources.
  8. HEAD: This method behaves like the HTTP GET method, the difference is that it only requires to return the HTTP headers, but does not need to return the HTTP body.
  9. OPTIONS: This HTTP method tells the server to list all the communication options for the request URL. The syntax is as below.
    OPTIONS /welcome.html HTTP/1.2
    OPTIONS * HTTP/1.2
    
    asterisk(*) means return the communication options for the entire server. Below is the response data example.
    
    HTTP/1.1 200 OK
    Cache-Control: max-age=604800
    Allow: OPTIONS, GET, HEAD, POST
    Date: Thu, 13 Oct 2016 11:45:00 GMT
    Server: EOS (lax004/2813)
    Expires: Thu, 20 Oct 2016 11:45:00 GMT
    Content-Length: 0
    x-ec-custom-error: 1

3. HTTP Method GET VS POST.

  1. The HTTP GET and POST methods are two mainly used HTTP methods. They are used in different use cases.
  2. The HTTP GET method is used when you do not need to submit a large amount of data. You can submit data by using this method also, but the submitted data length is limited to 2000 characters by default. Below is just an example of the URL for a Get method.
    # The first line format is as following.
    # HTTP-Request-Method/the-web-resource-path-on-the-web-server?request-parameters Protocol-Version
    GET/profile.jsp?user=abc&passwd=123 HTTP/1.1
    # Below are the request headers
    Host: www.dev2qa.com
    User-Agent: Mozilla/5.0
    Accept: text/xml,text/html,text/plain,image/jpeg
    Accept-Language: en-us,en
    Accept-Encoding: gzip
    Keep-Alive: 300
    Connection: keep-alive
  3. All the data send to the webserver is stored in the request header. Because your submitted parameter data is in the URL, so it is not secure. But you can easily reuse the URL to get the web page again.
  4. The HTTP POST method is used when you need to submit a massive amount of data.
  5. All the data send to the server is stored in the request body other than the header.
  6. The submitted data is secure because you can not see the data in the post URL. But this also makes it unreachable by simply copy and paste the request URL in your web browser.
0 0 votes
Article Rating
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x