I’m hoping this post isn’t off topic for this forum. I’m sending a http post to a REST endpoint leveraging HTTPotion and I’m getting the following response:
what’s confusing me is why HTTPotion is treating this as an error when the status_code is 200? I thought of capturing the raw request and response on the wire, but because the endpoint is encrypted, this isn’t an option.
Seems like the response doesn’t have Content-Length header set. The way HTTPotion represents the error is funny though. Seems like it just inspects the error tuple from ibrowse.
Just in case, there is a way to decrypt https requests with wireshark.
I “figured it out” by switching to HTTPoison and passing hackney: [:insecure]. When I switched to HTTPoison it stated that the CA was unknown, so with this option it works. Curious that HTTPotion didn’t provide a more meaningful error.
This is not related to the certificate. HTTPotion/ibrowse ignore the server’s certificate unless you explicitly opt-in to peer certificate verification, whereas HTTPoison/hackney enable server certificate verification by default. See https://blog.voltone.net/post/7 (still relevant 2 years later, unfortunately).
The root cause is the lack of the “Content-Length” header in the response, as @idi527 pointed out . HTTPotion/ibrowse consider that a malformed response, while HTTPoison/hackney apparently make a best-effort attempt to handle the response despite the protocol violation.