Re: Pass an htttpbody on a GET request with NSURLRequest
Re: Pass an htttpbody on a GET request with NSURLRequest
- Subject: Re: Pass an htttpbody on a GET request with NSURLRequest
- From: Antonio Nunes <email@hidden>
- Date: Sun, 05 Jul 2015 23:21:38 +0100
On 05 Jul 2015, at 15:42, Jens Alfke <email@hidden> wrote:
>
> If you have input into the API, then you might also point out that the credentials in the XML are redundant since they're already present in the Authorization header.
Hehe. That’s exactly what I did. The reply was: can you please do it the way we suggest? I figured, well, if they insist… But then it turned out not to be so easy. Hence this thread. :-)
Anyway, this is what Charles tells me about the curl request:
"
GET /api/v1/existing_user HTTP/1.1
User-Agent: curl/7.37.1
Host: example.com
Accept: */*
Accept-Encoding: gzip
Authorization: Basic blablabla
Accept-Language: nl, en-us
Content-Length: 122
Content-Type: application/x-www-form-urlencoded
<user><account_attributes><email>email@hidden</email><password>youllneverguess</password></account_attributes></user>
"
And this is what Charles tells me about the request through NSURLRequest:
"
GET /api/v1/existing_user HTTP/1.1
Host: example.com
Content-Type: application/x-www-form-urlencoded
User-Agent: TheApp/2.3.2 CFNetwork/711.3.18 Darwin/14.4.0
Connection: keep-alive
Accept: */*
Accept-Language: nl, en-us
Authorization: Basic blablabla
Accept-Encoding: gzip
Content-Length: 122
“
As you can see, the content body is not there.
> Two discrepancies: The request sent by NSURLSession is missing the Content-Type header, and has an Accept-Encoding header (which shouldn't be necessary because NSURLSession handles compressed responses for you.)
I’ve corrected the code to ensure the same headers are sent as per the curl call, and I’ve tried different combinations of headers, but all to no avail.
> Sending a request body with a GET is unusual, but I have no reason to think NSURLSession won't do it if you tell it to.
Well, from my tests, I’m starting to think this is exactly the problem, based on the output I get from Charles. It would seem it won’t do it.
-António
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden