HTTP Basics

HTTP Basics

HTTP basics

By decrypting the URL, you can see where to access it. The browser then accesses the web server using the HTTP protocol.  The HTTP protocol defines the contents and procedures of messages exchanged between the client and server. Use the URI when exchanging the message.

What is URI (Uniform Resource Identifier)

When sending a request message from the client to the server, the message describes “what” and “why” it wants, and the part corresponding to this “what” is called a URI. Specifically, it is as follows.

  • The name of the file that contains the data for that page

File name of CGI program: It defines rules for calling programs from Web server software, and programs that operate according to the rules are called CGI programs.

  • http: URLs that start with ~

This “what” describes the access destination to various data, and what collectively refers to such access destinations is called URI. Next, what is equivalent to “why” is called “method”. This method plays a role of telling the Web server what action you want it to do. Specifically, it is as follows.

  • I want you to read the data indicated by URI

I want you to pass the data entered on the client side to the program indicated by URI etc.

HTTP main methods

Table 1-1: Taking the main methods as a table looks like this. (HTTP version 1.1 or higher)

method role
GET Retrieve the information specified by the URI. In the case of a file, the contents of the file are sent back. In the case of a CGI program, the program data is directly sent back.
POST Send data from client to server. It is especially used when sending data entered in the browser form.
HEAD It is almost the same as GET, but it simply returns the HTTP message header, it does not return the contents of the data. Used to check attributes such as the last modified date of the file.
OPTIONS Used to notify communication options.
PUT Replace the file on the server specified by URI. If the file specified by the URI does not exist, a new file is created.
DELETE Delete the file on the server specified by URI
TRACE The request line and header received on the server side are directly sent back to the client. Used to check how the request is rewritten in an environment using a proxy server or the like.
CONNECT Method used when transferring encrypted message by proxy

  When the request message from the client arrives at the Web server, the Web server interprets its contents, examines the URI and method, judges what “what” and “what to do”, operates according to the request, and as a result Store the resulting data in the response message to the client. In the first part of it, give a status code indicating whether the execution result was successfully completed or more. For example, when an error occurs and accessing the Web server, the file may not be found and “404 Not Found” may be displayed, but this numerical value of 404 is called a status code. These codes are followed by the header field and page data, sent back to the client as a response message, and the client side browser retrieves the data from the message and displays it on the screen. This completes HTTP operation.

  • GET method

For the GET method, it is usually used to access the web server and read the data of the page. First write GET as the method of the request message and write the file name storing the data of the page in the URI. In other words, I will read the file data of the page sent here. When this message arrives at the Web server, the server fetches this file data, stores the data in the response message, and sends it back to the client. Then, the client side browser receives it and displays it on the screen.

  • POST method

The POST method is also one of the commonly used methods. This is used when sending the data entered in the form data to the web server. When using the POST method, describe the file name of an application program (mainly processing input data) that runs inside the Web server machine in the URI. (Forms such as index.cgi and index.php) And in the request message, in addition to the method and URI, data to be passed to the CGI program and script is also described. That data is the value the user entered in the field. When this request message arrives at the server machine, the Web server software passes the data described in the request message to the application program specified by the URI. Then, it receives the data output by the program, stores it in the response message, and sends it back to the client. HTTP uses two methods, GET and POST, to exchange page data while reading from the Web server and sending the data written in the fields in the page to the Web server. In addition, you can rewrite or delete Web server files from clients using PUT or DELETE. Clients using methods other than GET and POST are not widespread because of security problems and others, but by using methods like the table, it becomes possible to apply the HTTP protocol for various purposes It is.     


Leave a Reply

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