chris.sutcliffe
Confusion about HTTPotion response
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:
%HTTPotion.ErrorResponse{
message: "{:content_length_undefined, {:stat_code, '200'}, \"HTTP/1.1 200 OK\\r\\nContent-Type: application/vnd.dcp-v1+json\\r\\nDate: Wed, 19 Dec 2018 15:11:34 GMT\\r\\nAccess-Control-Allow-Origin: *\\r\\nAccess-Control-Allow-Methods: GET, POST, DELETE, PUT,OPTIONS\\r\\nAccess-Control-Allow-Headers: Content-Type, X-Access-Token\\r\\nAccess-Control-Expose-Headers: X-Access-Token\\r\\nSet-Cookie: c9c54d0c7a2119a88cbb4d1c8a1ef0d0=ed20f80f36ef856038563a2c27ff36ee; path=/; HttpOnly\"}"
}
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.
Any help would be greatly appreciated.
Thanks
Most Liked
idi527
![]()
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.
voltone
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.
axelson
I think your meant HTTPoison/hackney instead of HTTPotion/hackney (the last time you refer to it)
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








