A GET request is typically a network request that does not involve the user's account password, where the GET request is returned to the requested content before the next action can be made.
-(void) requestwithget{
GET Request:
1. Set the request path
NSString * Urlstr = [NSString stringwithformat:@ "http://192.168.1.53:8080/mjserver/login?username=%@&pwd=%@", Self.nametextfield.text,self.pawtextfield.text];
2. Create request object, not set, default to get
Nsurl * url = [Nsurl urlwithstring:urlstr];
3. Sending the request
}
A POST request can be used to send a login request for an account password because its URL does not show the contents of the account and password, so it is relatively secure, and some images are asynchronously downloaded and so on
-(void) requestwithpost{
POST request:
Set Request Path
Nsurl * url = [nsurl urlwithstring:@ "http://192.168.1.53:8080/"];
Create Request Object
Nsmutableurlrequest * request = [nsmutableurlrequest Requestwithurl:url];
Set request Timeout to 5 seconds
request.timeoutinterval=5.0;
Set Request method
[Email protected] "POST";
Set the request body
NSString *param=[nsstring stringwithformat:@ "username=%@&pwd=%@", Self.nameTextField.text, Self.pawTextField.text];
Convert the stitched string to data, set the request body
Request. Httpbody=[param datausingencoding:nsutf8stringencoding];
Send Request
}
Get requests and post requests in iOS development