iOS Development Web Chapter-Network request (HTTP protocol) summary
1. Talk about the HTTP protocol (the complete communication process for the Protocol)
2. Communication process
1> Request
* Client-to-server
* Content of the request
A. Request line (Request method \http protocol \ Request Resource Path)
B. Request header (information describing the client)
C. Request body (POST request only needs to have, store specific data)
2> response
* Server-to-client
* Content of the response
A. Status line (response line, status code)
B. Response header (server information, type of return data, length of returned data)
C. Entity content (response body, specific content returned to the client)
3.HTTP method of Request
1> GET
* Parameters are stitched behind the URL
* Parameters are Limited
2> POST
* Parameters are in the request body
* No restrictions on parameters
The means of sending get\post requests in 4.iOS
1> nsurlconnection
* Send a sync request
+ (NSData *) Sendsynchronousrequest: (nsurlrequest *) Request Returningresponse: (Nsurlresponse *) Response error: ( Nserror * *) error;
* Send an asynchronous request
+ (void) Sendasynchronousrequest: (nsurlrequest*) Request
Queue: (nsoperationqueue*) queue
Completionhandler: (void (^) (nsurlresponse* response, nsdata* data, nserror* connectionerror)) handler;
* Proxy method (async)
[Nsurlconnection connectionwithrequest:request delegate:self];
[[Nsurlconnection alloc] initwithrequest:request delegate:self];
[[Nsurlconnection alloc] initwithrequest:request delegate:self Startimmediately:yes];
Nsurlconnection *conn = [[Nsurlconnection alloc] initwithrequest:request delegate:self Startimmediately:no];
[conn start];