http (Hypertext Transfer Protocol), https

table of Contents

Introduction Section 1 HTTP

Section 2 HTTP message structure

Section 3 HTTP request method

The first HTTP response headers 4

Section 5 HTTP status code

Section 6 HTTP content-type

The first seven HTTPS

-------------------------------------------------------------------------------------------------------------------------------------------------

Introduction Section 1 HTTP

1. HTTP Introduction

HTTP protocol is the most widely used on the Internet A network transport protocol. All WWW documents must comply with this standard.

HTTP is used to transfer data (HTML files, image files, query results, etc.) based on TCP / IP communication protocol.

HTTP is used from the World Wide Web: Pass (www world wide web) server to the local browser hypertext transfer protocol.

2. HTTP principle

  • HTTP protocol works on the client - server architecture on. HTTP browser as a client by sending a request to the HTTP server URL

  • There are web server: Apache servers, IIS servers, etc.

  • The web server receives the request and sends a response message to the client.

  • The default HTTP port number is 80, but we can also be changed to 8080 or other ports.

3.HTTP Notes

  • HTTP is a connectionless: Meaning No limitation is attached only one request per connection. After the server processes client requests and receives the customer's response, i.e., disconnected. In this way it can save transmission time.

  • HTTP is an independent media: This means that, as long as the client and the server knows how to handle the data content of any type of data can be sent via HTTP. The client and server specify the appropriate MIME-type content type.

  • HTTP is a stateless: HTTP protocol is stateless protocol. No state is no protocol for transaction processing and memory. If the lack of state means that the subsequent processing required in front of the information, it must be retransmitted, which may result in the amount of data transmitted for each connection is increased. On the other hand, when it does not require previous information in response to a faster server.

4.HTTP communication flow

-------------------------------------------------------------------------------------------------------------------------------------------------

Section 2 HTTP message structure

1. HTTP message structure

HTTP is the client / server (C / S) model framework to exchange information via a secure link is a stateless request / response protocol.

A HTTP "client" is an application (Web browser or any other client), the purpose of the transmission of one or more HTTP request to the server by connecting to the server.

A HTTP "server" is also an application (typically a Web service, such as the Apache Web server or IIS server, etc.), by receiving the client's request is sent to the client HTTP response data.

HTTP uses uniform resource identifier (Uniform Resourse Identifiers, URI) to transmit data and establish a connection.

Once the connection is established, data on a similar message format used by the Internet Mail [RFC5322] and Multipurpose Internet Mail Extensions (MIME) [RFC045] to pass.

2. The client request message

The client sends a request to the HTTP server request message, including the following four parts:

Request line (request line), the request header (header), a blank line, the data request

3. The server response message

 HTTP response also consists of four parts: a status line, a message header, a blank line, the response body

4. Examples

-------------------------------------------------------------------------------------------------------------------------------------------------

Section 3 HTTP request method

1.HTTP request method

The standard HTTP, HTTP request can request a variety of ways.

HTTP1.0 request defines three ways: GET, POST, HEAD

HTTP1.1 request additional five ways: OPTIONS, PUT, DELETE, TRECE, CONNECT

method description
GET

Request page information specified, and returns the entity body.

HEAD Similar to get request, but the response is not returned in the specific content, for obtaining the header.
POST

向指定资源提交数据进行处理请求(例如提交表单或者上传文件)。数据被包含在请求体中。

POST请求可能会导致新的资源的建立和/或已有资源的修改。

PUT

从客户端向服务器传送的数据取代指定的文档的内容。

DELETE 请求服务器删除指定的页面。
CONNECT HTTP1.1协议预留给能够将连接改为管道方式的代理服务器。
OPTIONS 允许客户端查看服务器的性能。
TRACE 回显服务器收到的请求,主要用于测试或诊断。

-------------------------------------------------------------------------------------------------------------------------------------------------

第4节 HTTP响应头信息

1.HTTP响应头信息

HTTP请求头提供了关于请求,响应或者其他的发送实体的信息。

应答头 说明
Allow 服务器支持哪些请求方法(如GET、POST等)。
Content-Encoding 文档的编码(Encode)方法。
Content-Length 表示内容长度。
Content-Type 表示后面的文档属于什么MIME类型。
Date 当前的GMT时间。
Expires 应该在什么时候认为文档已经过期,从而不再缓存它?
Last-Modified 文档的最后改动时间。
Location 表示客户应当到哪里去提取文档。
Refresh 表示浏览器应该在多少时间之后刷新文档。
Server 服务器名字。
Set-Cookie 设置和页面关联的Cookie。
WWW-Authenticate 客户应该在Authorization头中提供什么类型的授权信息?

-------------------------------------------------------------------------------------------------------------------------------------------------

第5节 HTTP状态码

1.HTTP状态码

当浏览者访问一个网页时,浏览者的浏览器会向网页所在服务器发出请求。当浏览器接收并显示网页前,此网页所在的服务器会返回一个包含HTTP状态码的信息头(server header)用以响应浏览器的请求。

HTTP状态码的英文为HTTP Status Code。

2.常见的HTTP状态码

200: 请求成功

301:资源(网页等)被永久转移到其他URL

404:请求资源(网页等)不存在

500:内部服务器错误

3.HTTP状态码分类

分类 描述
1** 信息,服务器收到请求,需要请求者继续执行操作
2** 成功,操作被成功接收并处理
3** 重定向,需要进一步的操作已完成请求
4** 客户端错误,请求包含语法错误或无法请求完成
5** 服务端错误,服务器在处理请求的过程中发生了错误。

-------------------------------------------------------------------------------------------------------------------------------------------------

第6节 HTTP content-type

Content-Type,内容类型,一般是指网页中存在的Content-Type,用于定义网络文件的类型和网页的编码,决定浏览器将以什么形式、什么编码读取这个文件,这就是经常看到一些Asp网页点击的结果却是下载到的一个文件或一张图片的原因。

 

-------------------------------------------------------------------------------------------------------------------------------------------------

第7节 HTTPS

1. HTTPS原理

2.HTTPS缺点

 

-------------------------------------------------------------------------------------------------------------------------------------------------

HTTP 与 ​​​​​​​HTTPS 的区别

http是HTTP协议运行在TCP之上。所有传输的内容都是明文,客户端和服务器端都无法验证对方的身份。

https是HTTP运行在SSL/TLS之上,SSL/TLS运行在TCP之上。所有传输的内容都经过加密,加密采用对称加密,但对称加密的密钥用服务器方的证书进行了非对称加密。此外客户端可以验证服务器端的身份,如果配置了客户端验证,服务器方也可以验证客户端的身份

 

Guess you like

Origin blog.csdn.net/qq_25131799/article/details/82149272