Probably a good indication is that the NSURLRequest docs say this about the HTTPBody property.
Discussion This data is sent as the message body of a request, as in an HTTP POST request. Sent from my iPhone > On 2015/07/06, at 7:38, Antonio Nunes <[email protected]> wrote: > > Actually, > > One thing that I notice about the NSURLRequest call: it does state that the > Content-Length is 122, which would be the size of the content body if it were > there. But the body isn’t there. So now it’s starting to look like it may be > a bug in NSURLRequest(?) (And that might be why the server doesn’t know what > to do with the request, since it is told to expect a content of size 122, and > then the content is there…) > > -António > >> On 05 Jul 2015, at 23:21, Antonio Nunes <[email protected]> wrote: >> >> On 05 Jul 2015, at 15:42, Jens Alfke <[email protected]> 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 protected]</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 protected]) >> Help/Unsubscribe/Update your Subscription: >> https://lists.apple.com/mailman/options/macnetworkprog/devlists%40sintraworks.com >> >> This email sent to [email protected] > > > _______________________________________________ > Do not post admin requests to the list. They will be ignored. > Macnetworkprog mailing list ([email protected]) > Help/Unsubscribe/Update your Subscription: > https://lists.apple.com/mailman/options/macnetworkprog/dangerwillrobinsondanger%40gmail.com > > This email sent to [email protected]
_______________________________________________ Do not post admin requests to the list. They will be ignored. Macnetworkprog mailing list ([email protected]) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/macnetworkprog/archive%40mail-archive.com This email sent to [email protected]
