Synchronous requests, asynchronous requests, GET requests, POST requests for IOS, and iosget
Original link here: http://blog.csdn.net/liulala16/article/details/8271673
1. synchronous requests can request data from the Internet. O
Synchronous requests, asynchronous requests, GET requests, and POST requests for IOS
1. synchronous requests can request data from the Internet. Once a synchronous request is sent, the program stops user interaction until the ser
1. synchronous requests can request data from the Internet. Once a synchronous request is sent,ProgramUser interaction stops until the server returns data,2. asynchronous requests do not block the main thread, but create a new thread to operate. After the user sends an asynchronous request, the user can still operate the UI, and the program can continue to run.3. For a GET request, write the parameters dire
. Proxy method for asynchronous requests
This method is called when a server response is received
-(void) connection: (Nsurlconnection *) connection didreceiveresponse: (Nsurlresponse *) Response
{
Nshttpurlresponse *res = (Nshttpurlresponse *) response;
NSLog (@ "%@", [res allheaderfields]);
Self.receivedata = [Nsmutabledata data];
}
Called when the server transmits data, this method executes several times based on the size of the data
-(void
the Get and post in the header are two ways of requesting, synchronous and asynchronous are implementations, and get methods are synchronous and asynchronous, and there are two kinds of post. A little bit of web knowledge, to get and post should not be unfamiliar, often said request processing response, basically request is the two buddies, HTTP is the first defi
. Pay attention to cache issues for get requests. post requests do not need to worry about this issue.
2. For post requests, the Content-Type value must be set to application/x-form-www-urlencoded.
3. When sending a request, bec
request.
3. cache problem: GET requests need to pay attention to the cache problem. POST requests do not need to worry about this problem.
4. For post requests, the Content-Type value
response
Basic HTTP Response format
========================================================== ==============
[
==============================================
The only real difference is that the request line is replaced by the Status line in the first row. Status line describes the requested resources by providing a status code.
Status Code
Description
100 ~ 199
The request is successfully received, and the client is required to submit the next request to complet
invalid. The following problems may occur:
Missing or unknown request method
The request method is missing or unknown.
Missing URL
URL missing
Missing HTTP Identifier (HTTP/1.0)
Http id Missing (HTTP/1.0)
Request is too large
The request command is too long.
Content-Length missing for POST or PUT requests
The POST or PUT request lacks the content length.
Illeg
The simplest difference:
1. When using a GET request, the parameter is displayed in the URL and the Post method is not displayed
2. Use GET request to send the data quantity is small, the POST request sends the data quantity to be big
3.get request attention to cache problem, POST request do not need to worry about
The difference between the GET and POST methods of HTTP requestsIn the request-response between the client and the server, the two most commonly used methods are: GET and POST.
GET-Requests data from the specified resource.
POST-submits the data to be processed to the specified resource
Get methodNote
In doing Ajax page without refreshing add, ie under the AJAX cache, because at first didn't know that IE has this bad problem, toss for a long time, finally solve the problem. Summarize the solution:Under IE, the use of Ajax to request a page, usually because of the cache for the reason and return to the previous result, causing confusion, [ that is, get the data when it gets, because the sending parameters
-Favorites
GET requests should not be used when handling sensitive data
Get request has a length limit
GET requests should only be used to retrieve data
POST methodNote that the query string (name/value pair) is sent in the HTTP message body of the POST request:post/test/demo_form.php http/1.1Ho
When we load the network, there are two different ways to load the network. One is POST and the other is get.
1. Let's first look at the internal composition instances of the two request methods.
Get request:
GET /webservices/qqOnlineWebService.asmx/qqCheckOnline?qqCode=string HTTP/1.1Host: webservice.webxml.com.cnHTTP/1.1 200 OKContent-Type: text/xml; charset=utf-8Content-Length: length
string
Post
execute a curl session. the unique parameter is the handle returned by the curl_init () function. the function curl_close () is used to close a curl session. the only parameter is the handle returned by the curl_init () function.
3. basic steps for PHP to create a CURL request ①: initialize curl_init () ②: Set the attribute curl_setopt (). there is a long string of cURL parameters that can be set. they can specify the details of URL requests. ③: exec
request mode
Missing URL
Missing URLs
Missing HTTP Identifier (http/1.0)
Missing HTTP identifier (http/1.0)
Request is too large
Request command too long
Content-length missing for POST or PUT requests
POST or PUT request missing content length
illegal character in hostname; Underscores is not allowed
The host name contains illegal characters, and underscores ar
Get and Post requests
1. Request LengthRFC does not limit the length of Get and Post requests.However, the browser has restrictions. For example, the IE browser's Get request cannot exceed 2083 characters, and the Firefox browser cannot exceed 65536 characters. The browser has no restrictions on Post requests.The serve
The Caller class encapsulates Post and Get requests for both HttpURLConnection and HttpClient network access mechanisms, and adds the global cache mechanism. to use the cache mechanism, you must add the RequestCache class and initialize it in the onCreate method of the Application class of the project, and set it throu
To send the request to the server, we use the open () and send () methods of the XMLHttpRequest object:
Method
Description
Open (method,url,async)
Specifies the type of request, the URL, and whether the request is processed asynchronously.
method: type of request; GET or POST
URL: The location of the file on the server
Async: True (asynchronous) or false (synchronous)
This article mainly introduces how php uses the fsockopen function to send post and get requests to obtain webpage content. It is a typical application of PHP for socket programming. For more information, see
This article mainly introduces how php uses the fsockopen function to send post and get requests to obtain webp
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.