HTTP Overview

There are so many clients and servers exist in the word wide web. Today they are all connected together in a network which is called WWW network. They are connected use wires or wireless devices such as WIFI route. When you use your client such as iPhone to browse a page in the web. Your safari browser will send a request to the HTTP web server. After the HTTP web server receive your request, it will call 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 in the iPhone screen. This is just an example process of client server interaction mode.

web client server request response process architecture

HTTP Overview

HTTP is the abbreviation of Hypertext Transfer Protocol. It is used for web client and server to communicate. It is stateless that means it dose not maintain the communication state between the client and server. The client send the request and the server response to the client, after that the connection disconnected. If the client request again, the server will not remember that the client has do this before. It will treat the request from the same client as a new one. The advantage of this design is that the server can serve more clients at the same time.

the process of http web request and response

HTTP Methods

A client can use a number of methods to make the HTTP request. Each of these methods will let the server to perform a special action. Below table will list the methods and its purpose.

  1. GET : Request to get the specified url’s data from http server. The url can be a static resource such as html page, javascript, css and images, It also can be a dynamic web application such as a servlet or jsp page.
  2. POST : Ask server to receive the data posted by the client. We always use html form to post data to the server.
  3. PUT : Just like POST method, you can also use PUT to post data to the server. But the difference is that PUT can not only post data but also update the data posted before. With PUT method you can replaces all existing data using the updated content.
  4. CONNECT : This is a reserve method. It is used to tell the server to create a tunnel between client and the server.
  5. DELETE : Tell the server to delete some web resources.
  6. HEAD : This method like Get method, the difference is that it only require the http headers back do not need return the http body.
  7. OPTIONS :This method tell server to list all the communication options for the request url.The syntax is :

    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

GET VS POST

Get and POST are two mainly used HTTP methods. They are used in different use cases.

Get method is used when you do not need to submit 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 a picture of the URL for a Get method.

http get request method url explaination
All the data send to the web server 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.

POST method is used when you need to submit massive amount of data. All the data send to the server is stored in the request body other than the header. The submitted data is secure because you can not see the data in the post url. But this also make it unreachable by simply copy and paste the request url in your web browser. Below is just a POST request example.

http post request method explaination

(Visited 158 times, 2 visits today)
READ :   Java EE Application Introduction

Leave a Reply

Your email address will not be published. Required fields are marked *

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