A summary of HTTP

Main contents of this chapter:

  • How does the Web client communicate with the server
  • Where the resources come from
  • How do Web transactions work
  • The packet format used for HTTP communication
  • Underlying TCP network transport
  • Different HTTP protocol variants
  • Part of a large number of HTTP architecture components installed on the Internet

1.1 HTTP- Multimedia messenger for the Internet

I’ll focus on HTTP’s role in our use of the Web, which I’ll repeat here

Every day, hundreds of millions of JPEG images, HTML pages, text files, MPEG movies, WAV audio files, Java applets, and other resources cruise the Internet. HTTP can quickly, easily, and reliably move these chunks of information from Web servers around the world to Web browsers on people’s desktops.

HTTP uses a reliable data transfer protocol, so even if data comes from the other side of the world, it can be guaranteed that it won’t be corrupted or scrambled in transit. This way, users don’t have to worry about the integrity of the information when they access it, so it’s a good thing for users. This is also true for Internet application developers, who do not have to worry about HTTP traffic being corrupted, copied, or distorted in transit. Developers can focus on writing application-specific details without worrying about the pitfalls and problems of the Internet.

Let’s take a closer look at how HTTP transports Web traffic.

1.2 Web Client and Server

Web content is stored on a Web server. Web servers use the HTTP protocol and are often referred to as HTTP servers.

The client is our host, the server is the host that’s storing our stuff and we’re browsing content and we’re actually accessing stuff that’s stored on other computers and the host that’s providing stuff for us to access is figuratively called a server

When we (the client) access the server, we need to send a request. The server becomes an HTTP request and responds to our request with an HTTP response

1.3 resources

The Web server stores Web resources, that is, the Web server is the host of Web resources and the simplest web resources are static files in the web server file system, such as text files, HTML files, Word files, Adobe Acrobat files, JPEG image files, Avi movie files and so on

The resource does not have to be a static file. It can also be a software program that generates content on demand. For example: return “Hello user, it is now” + get the present time

In short, all types of content sources are resources

1.3.1 Media Types

HTTP carefully labels each object to be transferred over the Web with a data format called MIME Type.

A MIME type (which is a text token) represents:

content-type: image/jpeg
Copy the code

There’s a slash in the middle

  • HTML text documents: text/ HTML
  • Plain ASCII text documents: text/plain
  • Jpeg image format: image/ JPEG
  • GIF format: image/ GIF
  • Apple quickTime Movies: Video/quickTime
  • Microsoft PowerPoint: application/VND. Mspowerpoint

There are hundreds of common MIME types, and many more that are experimental or of limited use

1.3.2 URI

Uniform Resource Identifier

Each Web server resource has a name so that clients can say what resource they are interested in

Server Resource names, called Uniform Resource Identifiers (URIs), uniquely identify and locate information resources worldwide

Such as:

http://www.joes-hardware.com/specials/saw-blade.gif HTTP protocol is used to access www.joes-hardware.com for under the folder of the specials called saw - blade. GIFCopy the code

1.3.3 URL

Uniform Resource Locator

A URI is how a resource is uniquely identified, and that’s called a URI and a URL is identified by location, which is an implementation of a URI, right

Most urls follow a standard format that consists of three parts:

  • The first part (scheme): describes the protocol type used by the resource, such as http://
  • The second part: the Internet address of the server is given
  • The third part: specifies a resource on the Web server

Almost all URIs today use urls

Disadvantages of urls: You need to change the URL after changing the location of the resource

1.3.4 URN

Uniform Resource Name

URN is used as a unique name for specific content, independent of the current location of the resource

It lacks a supporting framework and is not currently being adopted on a large scale

Compare that to a URL, like a home address, and an ID number, and a URI is how do you identify a person

1.4 transactions

A transaction consists of a request command (sent from the client to the server, telling the server what I need) and a response result (sent from the server to the client, telling the client ok, here’s what you want). Okay

This communication takes place through formatted blocks of data called HTTP packets

1.4.1 method

HTTP supports several different request commands, which are called HTTP methods

Each HTTP request packet contains a method

The server performs actions based on methods

Methods the HTTP:

  • GET: Sends named resources from the server to the client
  • PUT: Stores data from the client to a named server resource
  • DELETE: deletes the named resource from the server
  • POST: Sends client data to a server gateway application
  • HEAD: Sends only the HTTP header in the named resource response

1.4.2 status code

Each HTTP response message returns with a status code indicating the result of the server’s response to your request. The status code is a three-digit number followed by a phrase (explanatory reason phrase text) such as: 200 OK indicates that the document returned correctly

404 not found 404 not found 404 not found

Chapter 3 explains HTTP status codes in detail

1.4.3 A Web page can contain multiple objects

When an application completes a task, it usually publishes multiple HTTP transactions. For example, if there are many images on a page, the browser will publish a series of HTTP transactions to fetch and display these images

The browser performs a transaction to get the HTML” frame “that describes the layout of the page

Any publish another HTTP transaction to get every embedded image, image panel, Java applet, etc

These embedded resources may not be on the same server, so a Web page is usually not a single resource but a collection of resources

1.5 a message

Chapter 3 takes a closer look at HTTP packets

The structure of HTTP request and response packets is as follows: HTTP packets are plain text and consist of simple strings. For example:

  1. Request message:
HTTP/1.0 header Accept: text/* Accept-language: en,frCopy the code
  1. The response message
// Start line HTTP/1.0 200 OK // header content-Type: text/plain Content-Length: 19 // body hi, here are some message!Copy the code
  • The request message

HTTP packets sent from the Web client to the Web server are called request packets

  • The response message

The packet sent from the server to the client becomes a response packet

HTTP packet structure:

  1. The starting line

    The first line of the message is the start line and it’s used in the request message to say what’s going on in the response message

  2. The first field

    After the start line there are zero or more header fields, each containing a name and a value. Use both: to split the header with an empty line ending

  3. The main body

    Contains all types of data request body: contains the data to be sent to the web server response theme: load the starting line and the first to return to the client’s data is text form and are structured And the main body can contain arbitrary binary data (such as images, video, software, etc.) subject, of course, also can contain text

Simple message example: After learning VUE, I want to do a project, but I need to use AXIOS, but I don’t know enough about computer network. Although the school offers the course of computer network, it mainly introduces TCP/IP, and the front-end needs more HTTP! Feel free. I’ve reopened T_T

A summary of HTTP

Main contents of this chapter:

  • How does the Web client communicate with the server
  • Where the resources come from
  • How do Web transactions work
  • The packet format used for HTTP communication
  • Underlying TCP network transport
  • Different HTTP protocol variants
  • Part of a large number of HTTP architecture components installed on the Internet

1.1 HTTP- Multimedia messenger for the Internet

I’ll focus on HTTP’s role in our use of the Web, which I’ll repeat here

Every day, hundreds of millions of JPEG images, HTML pages, text files, MPEG movies, WAV audio files, Java applets, and other resources cruise the Internet. HTTP can quickly, easily, and reliably move these chunks of information from Web servers around the world to Web browsers on people’s desktops.

HTTP uses a reliable data transfer protocol, so even if data comes from the other side of the world, it can be guaranteed that it won’t be corrupted or scrambled in transit. This way, users don’t have to worry about the integrity of the information when they access it, so it’s a good thing for users. This is also true for Internet application developers, who do not have to worry about HTTP traffic being corrupted, copied, or distorted in transit. Developers can focus on writing application-specific details without worrying about the pitfalls and problems of the Internet.

Let’s take a closer look at how HTTP transports Web traffic.

1.2 Web Client and Server

Web content is stored on a Web server. Web servers use the HTTP protocol and are often referred to as HTTP servers.

The client is our host, the server is the host that’s storing our stuff and we’re browsing content and we’re actually accessing stuff that’s stored on other computers and the host that’s providing stuff for us to access is figuratively called a server

When we (the client) access the server, we need to send a request. The server becomes an HTTP request and responds to our request with an HTTP response

1.3 resources

The Web server stores Web resources, that is, the Web server is the host of Web resources and the simplest web resources are static files in the web server file system, such as text files, HTML files, Word files, Adobe Acrobat files, JPEG image files, Avi movie files and so on

The resource does not have to be a static file. It can also be a software program that generates content on demand. For example: return “Hello user, it is now” + get the present time

In short, all types of content sources are resources

1.3.1 Media Types

HTTP carefully labels each object to be transferred over the Web with a data format called MIME Type.

A MIME type (which is a text token) represents:

content-type: image/jpeg
Copy the code

There’s a slash in the middle

  • HTML text documents: text/ HTML
  • Plain ASCII text documents: text/plain
  • Jpeg image format: image/ JPEG
  • GIF format: image/ GIF
  • Apple quickTime Movies: Video/quickTime
  • Microsoft PowerPoint: application/VND. Mspowerpoint

There are hundreds of common MIME types, and many more that are experimental or of limited use

1.3.2 URI

Uniform Resource Identifier

Each Web server resource has a name so that clients can say what resource they are interested in

Server Resource names, called Uniform Resource Identifiers (URIs), uniquely identify and locate information resources worldwide

Such as:

http://www.joes-hardware.com/specials/saw-blade.gif HTTP protocol is used to access www.joes-hardware.com for under the folder of the specials called saw - blade. GIFCopy the code

1.3.3 URL

Uniform Resource Locator

A URI is how a resource is uniquely identified, and that’s called a URI and a URL is identified by location, which is an implementation of a URI, right

Most urls follow a standard format that consists of three parts:

  • The first part (scheme): describes the protocol type used by the resource, such as http://
  • The second part: the Internet address of the server is given
  • The third part: specifies a resource on the Web server

Almost all URIs today use urls

Disadvantages of urls: You need to change the URL after changing the location of the resource

1.3.4 URN

Uniform Resource Name

URN is used as a unique name for specific content, independent of the current location of the resource

It lacks a supporting framework and is not currently being adopted on a large scale

Compare that to a URL, like a home address, and an ID number, and a URI is how do you identify a person

1.4 transactions

A transaction consists of a request command (sent from the client to the server, telling the server what I need) and a response result (sent from the server to the client, telling the client ok, here’s what you want). Okay

This communication takes place through formatted blocks of data called HTTP packets

1.4.1 method

HTTP supports several different request commands, which are called HTTP methods

Each HTTP request packet contains a method

The server performs actions based on methods

Methods the HTTP:

  • GET: Sends named resources from the server to the client
  • PUT: Stores data from the client to a named server resource
  • DELETE: deletes the named resource from the server
  • POST: Sends client data to a server gateway application
  • HEAD: Sends only the HTTP header in the named resource response

1.4.2 status code

Each HTTP response message returns with a status code indicating the result of the server’s response to your request. The status code is a three-digit number followed by a phrase (explanatory reason phrase text) such as: 200 OK indicates that the document returned correctly

404 not found 404 not found 404 not found

Chapter 3 explains HTTP status codes in detail

1.4.3 A Web page can contain multiple objects

When an application completes a task, it usually publishes multiple HTTP transactions. For example, if there are many images on a page, the browser will publish a series of HTTP transactions to fetch and display these images

The browser performs a transaction to get the HTML” frame “that describes the layout of the page

Any publish another HTTP transaction to get every embedded image, image panel, Java applet, etc

These embedded resources may not be on the same server, so a Web page is usually not a single resource but a collection of resources

1.5 a message

Chapter 3 takes a closer look at HTTP packets

The structure of HTTP request and response packets is as follows: HTTP packets are plain text and consist of simple strings. For example:

  1. Request message:
HTTP/1.0 header Accept: text/* Accept-language: en,frCopy the code
  1. The response message
// Start line HTTP/1.0 200 OK // header content-Type: text/plain Content-Length: 19 // body hi, here are some message!Copy the code
  • The request message

HTTP packets sent from the Web client to the Web server are called request packets

  • The response message

The packet sent from the server to the client becomes a response packet

HTTP packet structure:

  1. The starting line

    The first line of the message is the start line and it’s used in the request message to say what’s going on in the response message

  2. The first field

    After the start line there are zero or more header fields, each containing a name and a value. Use both: to split the header with an empty line ending

  3. The main body

    Contains all types of data request body: contains the data to be sent to the web server response theme: load the starting line and the first to return to the client’s data is text form and are structured And the main body can contain arbitrary binary data (such as images, video, software, etc.) subject, of course, also can contain text

Simple packet example: