Introduction to the

The current chapters, RFC7230-2.1 Client/Server Messages and RFC7230-2.2 Implementing Diversity, cover some basic definitions and some simple examples

In this series, you will learn about HTTP through your own understanding of it. If readers have different understanding, please share with me. If there is a mistake, please correct, I will be the first time to modify, so as not to mislead the reader.

Client

A program that establishes a connection with a server in order to send one or more HTTP requests

Server (server)

A program that serves HTTP requests by sending HTTP responses in order to accept connections

Client and Server represent only the role these programs play in a particular connection. That is, in different links, some servers may also be clients, and similarly, some clients may also be servers.

User Agent

Any client program that initiates a request, including but not limited to browsers, crawlers, and command-line tools. Custom apps and mobile apps.

Origin Server

A program that can create authoritative applications for a given target resource. Such as the server currently deployed to run the nuggets community.

Sender

Any implementation that sends a given message.

The Recipient

Any implementation that receives a given message.

Simplest two-way connection

HTTP relies on the Uniform Resource Identifier (URI) standard to identify target resources and relationships between resources. This can be done in the simplest case through a two-way connection between the User Agent (UA) and the Origin Server (O)

request

A client sends an HTTP request to a server in the form of a request message, starting with a request line and including a method, URI, and protocol version. Next, the header field contains the request modifier, client information, and presentation meta-information, an empty line indicates the end-of-header portion, and the last message body contains the body.

The response

A server responds to a request from a client by sending one or more HTTP response messages. Each HTTP response message already contains the protocol version, begins with a status line for a success or error code and a text cause phrase, may be followed by header fields containing server information, resource metadata, and presentation metadata, an empty line indicating the end of the header part, and finally the message body containing the payload body.

More than a pair of

A connection may be used for multiple request/response interactions

example

A GET request of URI is www.example.com/hello.txt a typical message exchange: the client request:

HTTP/1.1 user-agent: curl/7.16.3 libcurl/7.16.3 OpenSSL/0.9.7l zlib/1.2.3 Host: www.example.com Accept-Language: en, miCopy the code

Server response:

HTTP/1.1 200 OK
Date: Mon, 27 Jul 2009 12:28:53 GMT
Server: Apache
Last-Modified: Wed, 22 Jul 2009 19:15:56 GMT
ETag: "34aa387-d-1568eb00"
Accept-Ranges: bytes
Content-Length: 51
Vary: Accept-Encoding
Content-Type: text/plain

Hello World! My payload includes a trailing CRLF.
Copy the code

Implementation diversity

The user agent does not have to be a generic browser, nor does the original server have to be a large public web site

The document address

HTTP / 1.1 rfc7230