Unity Common Network Framework and actual combat analysis
1.Http protocol
HTTP protocol
exists above TCP sometimes tls\ssl default port above HTTPS default port is 443
HTTP Request Response Model HTTP protocol is always the client sends the request, the server side will send the response
HTTP Workflow 1. Connection 2. Request 3. Response (Response)
HTTP request Response Message
Request requests
Request Message Format
Request line Generic message touch| request Header | Font header
Request Line = method "Space" HRL "space" version number "carriage return line"
Common Request Methods (get| Post)
Responnse response
Request Message Format
General Message Header Response Header entity header
HTTP status Code
Status code
1XX: Indicates that the request has been accepted and continues processing
2XX: Accept Request
3XX: Redirect, you must take a closer step to complete the request
4XX: Client error, request syntax error or request not implemented
5XX: Server Error
Common Status Codes
Ok
The Bad Request
401 Unauthorized Server not authorized
403 Forbidden Forbidden
404 Not Found
Internal Server Error
503 Server Unavailabl
The difference between 2.Get and POST request modes
Get is a form value passed through a URL, and the form value that is passed by post is implicit in the HTTP message, which is not visible in the URL.
Get request format for passing data by URL
The file name requested in the URL followed by "? ", and then add the message to be uploaded key and value values
Multiple sets of key-value pairs, with "&" between key-value pairs
The URL contains Chinese characters, special symbols, which need to be encoded.
Get passes the amount of data is limited, if you want to pass a large amount of data can not be used to get, to use post.
Get
Advantages: Easy to test, simple and clear
Cons: Less information, less security
Post
Advantages: Large amount of information, relatively high security
Cons: Test not very convenient
Gjm:unity3d Common network Framework and practical analysis of "notes"