I'm using PromiseKit in an IOS app to communicate with a Rails RESTful backend,
and there're some calls that return only header, say by executing head 200
on the backend.
What I've tried is:
I used [NSURLConnection POST:url formURLEncodedParameters:parameters]
to post data to backend, the backend did receive the data and responded with a head 200
message, but PromiseKit is reporting the following exception:
2014-07-31 11:19:39.501 HelloPOS[13223:60b] Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (No value.) UserInfo=0xa4c5a90 {NSDebugDescription=No value., PMKURLErrorFailingDataKey={length = 1, capacity = 16, bytes = 0x20}, PMKURLErrorFailingURLResponseKey= { URL: http://SOME_APP.SOME_HOST.com/api/v1/sales.json } { status code: 200, headers { "Cache-Control" = "max-age=0, private, must-revalidate"; Connection = "keep-alive"; "Content-Length" = 1; "Content-Type" = "application/json"; Date = "Thu, 31 Jul 2014 03:19:25 GMT"; Etag = "\"7215ee9c7d9dc229d2921a40e899ec5f\""; Server = "WEBrick/1.3.1 (Ruby/2.0.0/2014-05-08)"; Via = "1.1 vegur"; "X-Content-Type-Options" = nosniff; "X-Frame-Options" = SAMEORIGIN; "X-Request-Id" = "5a1c1aa1-4b42-41ea-8397-a5df8fa956bc"; "X-Runtime" = "0.013359"; "X-Xss-Protection" = "1; mode=block"; } }}
It's probably because header-only response has no body, and the error is caused
PS: I've changed the URL in the exception message