Chapter 4 returns the HTTP status code for the result

The HTTP status code is responsible for representing the return result of the CLIENT’S HTTP request, marking the normal processing of the server, and notifying the error.

1. 2XX is successful

200 OK

The request from the client is processed normally on the server.

204 No Content

The request received by the server is successfully processed, but the response message returned does not contain the body part of the entity. Also, it is not allowed to return the body of any entity. For example, when a 204 response is returned after processing a request from the browser, the page displayed by the browser is not updated.

This is usually used when only information needs to be sent from the client to the server, and no new information content needs to be sent to the client.

206 Partial Content

The client makes a scope request, and the server successfully executes that part of the GET request.

2. 3XX redirect

301 Moved Permanently

Permanent redirection, which indicates that the requested resource has been assigned a new URI and should later be saved at the URI indicated in the Location header field.

302 Found

A temporary redirect that indicates that the requested resource has been assigned a new URI and is expected to be accessed by the user (this time) using the new URI.

This is usually used when only information needs to be sent from the client to the server, and no new information content needs to be sent to the client.

303 See Other

The GET method should be used to GET the requested resource because another URI exists for the resource corresponding to the request.

302 and 303 differ: the function is the same, but 303 explicitly states that the client should use the GET method to obtain resources. When the 301, 302, and 303 response status codes return, almost all browsers change POST to GET and remove the body of the request message, and the request is automatically sent again.

304 Not Modified

A condition in which the server allows the request to access a resource when the client sends a conditional request, but the condition is not met. Return with no body part of the response.

Conditional request: GET request packets contain if-match, if-modifiedSince, if-none-match, if-range, or if-unmodified-since headers.

3. 4XX client error

400 Bad Request

A syntax error exists in the request packet. Modify the request content and send the request again.

401 Unauthorized

The sent request needs to have HTTP authenticated information.

This is usually used when only information needs to be sent from the client to the server, and no new information content needs to be sent to the client.

403 Forbidden

Access to the requested resource is denied by the server, access authorization is not granted to the file system, or access permissions are compromised (an unauthorized sending source IP address attempts to access the requested resource).

404 Not Found

The requested resource could not be found on the server. In addition, the server may reject the request without giving a reason.

4. 5XX server error

500 Internal Server Error

There is an error on the server side executing the request, or a bug in the Web application or some temporary glitch.

503 Service Unavailable

The server is temporarily overloaded or is being shut down for maintenance.

Chapter 5 Web Servers that collaborate with HTTP

The HTTP/1.1 specification allows a single HTTP server to Host multiple Web sites by leveraging Virtual hosts (also known as Virtual servers). At the same IP address, the virtual Host can Host multiple Web sites with different Host names and domain names, so when sending HTTP requests, you must specify the URI of the Host name or domain name in the Host header.

Communication data forwarding program: proxy, gateway, tunnel, can forward the request to the next station on the communication line server, and can receive the response sent from that server and forward to the client.

First, agent – forwarding

Multiple proxy servers can be cascaded during HTTP communication. When forwarding, you need to attachViaHeader field to mark the passing host information.

Classification:

  • Caching or not: A Caching Proxy stores copies of resources on the Proxy server. When the proxy receives a second request for the same resource, it can not fetch the resource from the source server, but return the previously cached resource as a response.
  • Whether to modify packets: Transparent Proxy does not process packets. Otherwise, it is called an opaque Proxy.

Function:

  • Using caching technology to reduce the traffic of network bandwidth;
  • Access control within an organization for specific web sites, mainly for the purpose of obtaining access logs

Gateway – handles requests like a source server that owns its own resources

The gateway enables the server on the communication line to provide non-HTTP services.

Function:

  • Enhanced communicationsecurityBecause the communication line between the client and the gateway can be encrypted to secure the connection.

3. Tunnel – transfer between clients and servers that are far apart

A tunnel can establish a communication line with other servers as required and use encryption methods such as SSL to communicate. The tunnel itself does not parse HTTP requests.

Function:

  • Ensure that the client can securely communicate with the server

Caching (a supplement to caching proxy servers)

  • Valid term

Even if a cache exists, the validity of the resource is confirmed to the source server due to factors such as client requirements and cache validity. If the cache is deemed invalid, the cache server will fetch the “new” resource from the source server again.

  • Client side cache

If the browser cache is valid, it does not have to request the same resource from the server and can be read directly from the local disk. When the cache is determined to be expired, the validity of the resource is verified with the source server. If the browser cache is invalid, the browser requests new resources again.