Server and browser communications rely on the HTTP protocol, today to analyze the specific content of the HTTP protocol and HTTPS encryption process. In addition to these protocols, in order to increase the scalability of server and browser interaction, there is also a restful style of request, easy to invoke the interface. An overview of the HTTP protocol
1. Client and server side
2. Resources
html/text, Word, AVI movie, Other resources
3. Media type
MIME type (tells the browser how to resolve this type). Text/html, Image/jpeg
4. Uri and URL
Uri:web the name of the server resource. Index.html
Url:http://www.gupaoedu.com:80/java/index.html[?query-string] #location
Analysis (Protocol):
Schema:http/https/ftp.
IP address or domain name of the Host:web server
Port: Server port, HTTP default access is 80
Path: Resource access Path
Query-string: Query Parameters
#location: Anchor Point (positioning)
5. Methods
Get/put/delete/post/head
Message
Request parameter, Response response parameter
The request message structure contains three parts: (Start line, header field, body)
Method/path/http/version-number
Header-name:value
Blank Line
Body Optional Request body
Response
Http/version-number Status Code message
Header-name:value
Body
Status code
Five types of status codes are defined in the http/1.1 version of the Protocol
1XX Tip Information
2XX success
3XX redirection
4XX Client Error
5XX Server-side error
Cache
The server can set whether to use the cache in the returned response
Features of the HTTP protocol
1. No status
Cookie+session (keep the server state)
2. Multiple requests
3. TCP protocol based
HTTPS
One more encryption on the HTTP protocol
SSL/TLS (encryption)
SSL3.0
ISOC released the upgrade version on the basis of SSL TLS1.2
How HTTPS works
Encrypt on HTTP basis
The first step is to use symmetric plus decryption
The second step, the key is public, all the clients can get (this may be intercepted)
The third step uses different keys for different clients
Problem: The negotiation process is not encrypted, so there will be truncated issues
Fourth step: Using asymmetric encryption
Asymmetric: The concept of public and private keys
Problem: How the client gets the public key
1. Server-side sends the public key to each client
2. Server side put the public key to the remote server, the client can request to
3. Let the browser save All public keys (unrealistic)
The fifth step of the public key is switched to the problem according to the above scheme, always exists.
Sixth step: Use a third-party organization to solve
Using a third party's private key to encrypt the public key we need to transfer through a third-party organization
Seventh part
What is included in the digital certificate:
Company Information, website information, digital certificate algorithm, public key
Connection process
Restful
REST Representational State transitions
Use Web standards to do some guidelines and constraints.
Basic concepts of restful
1. In rest, everything is considered a resource
2. Each resource is uniquely identified by a URI
3. Processing resource requests using a unified interface (Post/get/put/delete/head)
4. No status
Resources and URIs
1. [/] Indicates the hierarchical relationship of resources
2.? Filter resources
3. Use _ or-make the URI more readable
Unified interface
Get gets a resource. Power, etc.
POST to create a new resource
PUT replaces an existing resource (update operation), idempotent
Delete Deletes a resource
Patch/head
Resource presentation
MIME type ()
Accept:text/xml HTML file
Content-type tells the client the presentation of the resource
Resource Links
Hypermedia is the application state engine
State transitions
The server side should not save the client state.
App status-> Server side does not save app State
Access orders according to the interface to query
Visit Product Enquiry
The best design for restful
1. Domain Name
HTTP/api.gupaoedu.com
HTTP/Api/gupaoedu.com/api
2. Version
HTTP/api.gupaoedu.com/v1/user/1
Inside the header maintenance version
3. Path
http/api.gupaoedu.com/v1/users_list//Get user list
http//Api.gupaoedu.com/v1/goods-list //Product List
http/api.gupaoedu.com/v1/users/ {ID}
4. Filtering information
https://api.github.com/user/repos?page=2&per_page=100
https://developer.github.com/v3/#rate-limiting
5. Status Code
Business Status Code
HTTP status Code
1.4 Distributed-Communication protocol TCP/IP