IOS development network-Summary of network requests (HTTP Protocol) and ios Summary

Source: Internet
Author: User

IOS development network-Summary of network requests (HTTP Protocol) and ios Summary

IOS development network-Summary of network requests (HTTP Protocol)

 

1. Talk about the HTTP protocol (the complete communication process of the Protocol)

 

2. Communication Process

1> request

* Client --> Server

* Request content

A. Request Line (Request Method \ HTTP protocol \ request resource path)

B. Request Header (description of client information)

C. Request body (only POST requests are required to store specific data)

 

2> response

* Server --> Client

* Response content

A. Status line (Response line, Status Code)

B. Response Header (server information, type of returned data, length of returned data)

C. entity content (response body, specific content returned to the client)

 

3. HTTP Request Method

1> GET

* Parameters are spliced after the URL

* Parameter restrictions

 

2> POST

* Parameters are in the Request body.

* The parameter is not limited.

 

4. Methods for sending GET/POST requests in iOS

1> NSURLConnection

* Send a synchronous 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 (asynchronous)

[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];

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.