Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
default emptyResponseAllows returns false unless HTTP Method is .head #2770
What did you do?
I'm deserializing a response from an HTTP PUT Method and returns an empty status code (204).
What did you expect to happen?
My instinct was that ResponseSerializer.emptyResponseAllowed(forRequest:response:) would return true if either the http method was HEAD or the status code was 204/205.
If I were to have written this method, it would have looked like this:
What happened instead?
It appears that in the default case, the code returns true only if the http method is HEAD AND the status code to be 204/205. Below is the current code.
Again, I'm merely asking if this is logical AND is intentional or not.
The workaround is easy: just need to explicitly enumerate all of the HTTP methods that can return empty responses.
Alamofire version: 5.0.0-beta3
I've just encountered this issue today morning, after updating from v4.8 to v5 beta 3. And noticed that server responses with code 204 and empty body started to be handled as errors with "Alamofire.AFError.ResponseSerializationFailureReason.inputDataNilOrZeroLength" error.