I am sending a response with the 204 like this:
|> send_resp(204, Jason.encode!("Record Deleted"))
I got the response successfully in my test cases, but when I test it with Postman it gives me:
Could not get any response
If I remove the message, and send it like this it works.
|> send_resp(204, ""))
It was working with postman one time, but I don’t know why its not working now.
Any suggestions or ideas?
Although this status code is intended to describe a response with no body, servers may erroneously include data following the headers. The protocol allows user agents to vary in how they process such responses (discussion regarding this specification text can be found here). This is observable in persistent connections, where the invalid body may include a distinct response to a subsequent request.
Apple Safari rejects any such data. Google Chrome and Microsoft Edge discard up to four invalid bytes preceding a valid response. Firefox tolerates in excess of a kilobyte of invalid data preceding a valid response.
So I’m not sure you actually want to send data with a 204.
Thanks for your answer. Yes I get your point. But I am just curious why it’s working with tests but not with Postman.
Afaik the conntests don’t go though cowboy, but are dispatched directly on the endpoint module. So you’re only working with
Plug.Conn and not raw http messages.