In which language is the http protocol written

The HTTP request: get data from the server

HTTP - Hypertext Transfer Protocol

The most prominent protocols on the Internet are HTTP (Hypertext Transfer Protocol) and FTP (File Transfer Protocol). POP3 is a protocol for retrieving emails, SSH (Secure Shell) is an encrypted terminal for remote access to the server.

If the user enters an address in the address field of his browser or sends a form to the address in the action attribute, the address is sent to the server as an HTTP request. The browser is the HTTP client and the server is the HTTP server.

HTTP is a stateless protocol. After a data transfer, the connection between the client and the server does not have to be maintained.

When further data is transferred, the client must establish a new connection that does not know anything about the previous process. For a website with four images and a stylesheet, six more requests were required with the HTTP 1.0 protocol, whereas the HTTP 1.1 protocol could exchange several requests and responses within one connection and continue broken connections.

HTTP 2

HTTP / 2 has been the new standard since 2015 - with better performance than HTTP / 1.1, better compression of the HTTP header and, above all, thanks to the multiplexing of several simultaneous requests on the same connection.

HTTP / 2 does not bring the big breakthrough in speed, because HTTP / 2 has remained compatible with HTTP / 1.1 and also requires an encrypted connection (HTTPS), which extends the transfer a bit. But thanks to the compatibility, the dear old functions from cookies to GET and POST are retained.

Cookies and Query Strings

But even with HTTP / 2, the HTTP protocol has no memory. In order to transfer information from one HTML page to the next (e.g. with multi-page forms), procedures such as cookies, query strings or PHP sessions must be used.

HTTP request and HTTP response

After establishing a connection to the server, the HTTP client transmits a request in a specified format:

  • an initial line
  • a series of header lines
  • a blank line
  • a message (optional)

The initial three-part line consists of the name of the method, the path to the requested resource and the HTTP version used. A typical query can look like this

HTTP 1.1 request

(A fully qualified URL and the HOST header line required)

GET http://wisotop.de/test.html HTTP / 1.1 HOST: wisotop.de

Header lines send additional information about the request or the data of the message body, e.g. the desired language. Each header line notes a name / value pair, where the name and value are separated by a colon.

User-Agent: Mozilla / 5.0 (Macintosh; U; PPC Mac OS X Mach-O; de; rv: 1.8.0.4) Gecko / 20060508 Firefox / 1.5.0.4 Accept: * / *

The accept field signals to the server which formats the client accepts. Since modern servers can process almost all formats, the MIME type * / * is usually used.

HTTP response

In response to such a request, the server sends an HTTP response, the first line also being referred to as the status line. In this line, the server returns the HTTP version as an echo as well as a response status code in the form of three digits and a short text message, which is referred to as the reason phase.

HTTP / 1.1 200 OK Server: Apache / 2.0.49 Content-Language: de Content-Type: text / html User-Agent: Mozilla / 5.0 (Macintosh; U; PPC Mac OS X; de-de) AppleWebKit / 312.8

The response status code and the reason phase are plain text messages from the same message, although the reason phase may vary slightly from server to server.

1 ** - information
Information messages
2 ** - Success
The request was successfully carried out
200 - OK
The request was successful
204 - No content
The document does not contain any data
3 ** - Redirected
Further information is required for a successful processing of the request
301 - Moved Permanently
The requested document has permanently moved to a different URI
4 ** - Client error
Probably the cause of the failure of a request lies with the client
401 - Not Authorized
The request must be authenticated by the user
403 Forbidden
The server rejects the request
404 - Not Found
The requested resource does not exist
5 ** - Server error
500 - Internal Server Error
the cause of the failure of a request is likely to be with the server
503 - Service Unavailable

The response can also contain header lines, each of which consists of a header and a value pair.

HTTP Status Code: HTTP / 1.1 200 OK Server: Apache / 2.0.49 (Linux / SuSE) Date: Thu, 13 Jul 2006 07:19:43 GMT Content-Type: text / html Connection: close

The HTTP request methods

We are familiar with the methods of HTTP requests as soon as we put the first form on a website. The encounter is limited to the GET and POST methods.

GET
Request content from the server.
POST
Request content from the server and also transmit a data block made up of name / value pairs (e.g. from a form). In principle, data can also be transferred with GET, but the amount of data permitted with POST is greater.
HEAD
instructs the server to send the HTTP header but not the content of the document. For example, the existence of a linked page can be checked.
PUT
Upload files to the web server. Hardly implemented for security reasons.
DELETE
deletes the file on the server. Hardly implemented for security reasons.
TRACE
returns the request as the server received it. Is used e.g. for debugging connections, but is not implemented on many servers for security reasons.
CONNECT
is implemented by proxy servers
PATCH
Changes to a resource

HTTP / 1.1 and HTTP / 2

HTTP1 was defined in 1996 when web pages rarely exceeded 20 KB, when CSS was still above the clouds and Javascript was only used to validate forms and simple effects.

HTTP / 1.1 was introduced in 1997, updates were made in 1999 and 2014. The most important difference is likely to be the support for multiple connections per request. Multiple connections - this brings a shorter latency period (delay between request and response).

HTTP / 2 is the most recent version. The server can transfer data that has not yet been requested by the client, but which is needed for the complete display of the page. HTTP / 2 can bundle additional requests over a single TCP connection and transmit them at the same time - waiting for the answer: shorter waiting times.

Both the server and the client must support HTTP / 2 - all modern browsers can do this. If the server supports HTTP / 2, the browser automatically fetches the pages via HTTP / 2. HTTPS required: If the browser cannot negotiate an encrypted connection, it will fall back on the HTTP / 1.1 protocol.

HTTP / 2 - Impact on Web Design

Even if HTTP / 2 does not give websites wings and is more or less barely noticed by the user, the use of HTTP / 2 has an impact on web design.

Where previously Image Spites put many relatively small images together into one large image so that the CSS picked them apart again, this time-consuming process can be saved with HTTP / 2 in many cases. The same applies to the compilation of large Javascript files from the large number of scripts used and also to CSS files. With HTTP / 2, these methods no longer have the same advantages as in HTTP / 1.1, but may have new disadvantages:

  • The user is served large files, of which he may only actually need a part. With HTTP / 2 it makes more sense to use resources efficiently only where they are needed.
  • A Base64 data URL is also rather counterproductive compared to integrating the file.
  • HTTP2 cannot cache inline content. Modular external CSS and Javascript files, on the other hand, can be cached efficiently without requesting an additional request to the server.

The visible speed advantages are - as already mentioned - not an intoxicating flight of highs, but rather when considering the loading time of individual pages well, nice. The advantages of HTTP 2 become visible in the overall assessment when there are high numbers of visitors.

You can test in the Chrome console whether the pages are delivered via HTTP 1.1 or HTTP 2:

console.log (performance.getEntries () [0] .nextHopProtocol)

With HTTP2 the answer is short and sweet h2, otherwise http / 1.1.

External sources