how do I check an http request response status code from iOS?
I am sending an http request from iOS (iPad/iPhone) to my python google app engine server using the
How do I read the response’s status, i.e. the value set by app engine using
response.set_status(200, message="Success") for instance?
I’m not able to find where I can read these status codes once I receive the
connectionDidFinishLoading delegate call on the client end.
2 Solutions Collect From Internet About “how do I check an http request response status code from iOS?”
connection:didReceiveResponse: delegate method is called when a response is received, which gives you an
NSURLResponse to play with.
If you’ve made an HTTP request, then it’ll actually be an
NSHTTPURLResponse object, which has a
If you are sending a synchronous request, you could get the response code from NSHTTPURLResponse.
NSHTTPURLResponse *response = nil; NSError *error = nil; NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:URL_LOGIN]]; NSData *respData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error]; NSLog(@"~~~~~ Status code: %d", [response statusCode]);
Hope this will help you 🙂
- NSURLSessionTask. Suspend does not work
- iOS stop global queue from running
- iPhone simulator isn't showing splash screen
- Swift 3 init method that accepts JSON with optional parameters
- Subclassing an NSDrawer's contentView to implement a completely custom drawer
- “Combine High Resolution Artwork” in XCode 4?
- Can we do VOIP push notification using Twilio iOS SDK?
- How to use CMAltitudeHandler in Swift?
- Speeding up page transitions in jQuery Mobile 1.1 for iPhone apps built with PhoneGap?
- Google OAuth no longer supported for progressive applications?
- How to add facebook open source code pop to project directly
- How to transpose an array of strings
- Iterate over static properties of a struct
- Compiling and linking C extension for Python in Xcode for Mac
- Snapshot of MKMapView in iOS7