chris.sutcliffe

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

idi527

:wave:

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

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

axelson

Scenic Core Team

I think your meant HTTPoison/hackney instead of HTTPotion/hackney (the last time you refer to it)

voltone

voltone

Damn those HTTPuns, yes, thanks

Where Next?

Popular in Questions Top

sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
gonzofish
I’m currently trying to understand how to join three tables using Ecto. All the examples I’ve seen use 2, so maybe I’m just missing somet...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
chewm
Hi guys, nice to meet you to the whole forum, I’m new here, I’m trying to configure visual studio code for elixir, right now the intellis...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

Other popular topics Top

JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 45766 226
New
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
New
AstonJ
by Lance Halvorsen Elixir and Phoenix are generating tremendous excitement as an unbeatable platform for building modern web application...
460 27162 124
New

We're in Beta

About us Mission Statement