Hello.
I am not sure, it’s right place for question.
We use passenger with apache. Api responds with 204 via “head
:no_content”
– ActionController/Head.html
response (tcpdump output):
HTTP/1.1 204 No Content^M
Date: Wed, 15 Jul 2015 13:05:41 GMT^M
Server: Apache/2.4.7 (Ubuntu)^M
Cache-Control: no-cache^M
X-Runtime: 0.025314^M
X-Request-Id: 28bdd133-29c6-4176-a9a5-edcb628d9a19^M
X-Powered-By: Phusion Passenger 5.0.14^M
Transfer-Encoding: chunked^M
Status: 204 No Content^M
Content-Length: 0^M
Connection: close
but according (RFC 7230):
A sender MUST NOT send a Content-Length header field in any
message
that contains a Transfer-Encoding header field.
plus
A server MUST NOT send a Transfer-Encoding header field in any
response with a status code of 1xx (Informational) or 204 (No
Content). A server MUST NOT send a Transfer-Encoding header
field in
any 2xx (Successful) response to a CONNECT request (Section 4.3.6
of
[RFC7231]).
As the result we got this error on ios:
Error Domain=NSURLErrorDomain Code=-1017 "cannot parse response"
UserInfo=0x1740eb880 {NSUnderlyingError=0x174051be0 “cannot parse
response”, NSErrorFailingURLStringKey=api-url,
NSErrorFailingURLKey=api-url, kCFStreamErrorDomainKey=4, kCFStreamErrorCodeKey=-1,
NSLocalizedDescription=cannot parse response}
I make a dirty workaround
headers['Content-Length'] = 0
after “head :no_content”, it’s remove “Transfer-Encoding: chunked”
according rfc7230#section-3.3.2
A server MUST NOT send a Content-Length header field in any response
with a status code of 1xx (Informational) or 204 (No Content).
I think there is passenger or apache bug (maybe documentation or
settings
lack). What should I do?
// and sorry for my poor English