[erlang-questions] Cowboy Crash with Postman works fine with CURL

Loïc Hoguin essen@REDACTED
Tue Apr 2 21:06:50 CEST 2019


Your hello_post function is returning Req instead of {boolean(), Req, 
State}.

On 02/04/2019 17:04, maverik a wrote:
> Hi Erlangers,
> 
> I'm learning Cowboy and facing a peculiar issue.
> *My handler code* is here. <https://pastebin.com/NQsrj1g0>
> 
> I have a rest endpoint (POST) and accessing it with Postman show a crash 
> report after giving response. But the very same request works find with 
> CURL.
> 
> _*CURL Request*:_
> curl -X POST -d '{"name":"M4ver1k"}' -i -H "User-Agent: 
> PostmanRuntime/7.6.1" -H "Cache-Control: no-cache" -H "postman-token: 
> cc241d1b-d2f0-488d-86ec-0a06bbb13234" -H "connection: keep-alive" -H 
> "Accept-Encoding: gzip, deflate" -H "Content-Type: application/json" -H 
> "Accept: application/json" http://localhost:8080/api/
> 
> _*Crash Report:*_
> crasher:
>      initial call: cowboy_stream_h:request_process/3
>      pid: <0.1023.0>
>      registered_name: []
>      exception error: no try clause matching
>                       #{bindings => #{},body_length => 17,cert => undefined,
>                         charset => undefined,has_body => true,
>                         has_read_body => true,has_sent_resp => true,
>                         headers =>
>                             #{<<"accept">> => <<"application/json">>,
>                               <<"accept-encoding">> => <<"gzip, deflate">>,
>                               <<"cache-control">> => <<"no-cache">>,
>                               <<"connection">> => <<"keep-alive">>,
>                               <<"content-length">> => <<"17">>,
>                               <<"content-type">> => <<"application/json">>,
>                               <<"host">> => <<"localhost:8080">>,
>                               <<"postman-token">> =>
>                                   
> <<"04b305c1-5214-461e-a1c3-8dcd6b80a621">>,
>                               <<"user-agent">> => 
> <<"PostmanRuntime/7.6.1">>},
>                         host => <<"localhost">>,host_info => undefined,
>                         media_type => {<<"application">>,<<"json">>,[]},
>                         method => <<"POST">>,path => <<"/api/">>,
>                         path_info => undefined,
>                         peer => {{127,0,0,1},59002},
>                         pid => <0.1022.0>,port => 8080,qs => <<>>,
>                         ref => my_http_listener,scheme => <<"http">>,
>                         sock => {{127,0,0,1},8080},
>                         streamid => 1,version => 'HTTP/1.1'}
>        in function  cowboy_rest:call/3 
> (/m4ver1k/learn/erlang/hello_cowboy/_build/default/lib/cowboy/src/cowboy_rest.erl, 
> line 1576)
>        in call from cowboy_rest:process_content_type/3 
> (/m4ver1k/learn/erlang/hello_cowboy/_build/default/lib/cowboy/src/cowboy_rest.erl, 
> line 1100)
>        in call from cowboy_rest:upgrade/4 
> (/m4ver1k/learn/erlang/hello_cowboy/_build/default/lib/cowboy/src/cowboy_rest.erl, 
> line 288)
>        in call from cowboy_stream_h:execute/3 
> (/m4ver1k/learn/erlang/hello_cowboy/_build/default/lib/cowboy/src/cowboy_stream_h.erl, 
> line 296)
>        in call from cowboy_stream_h:request_process/3 
> (/m4ver1k/learn/erlang/hello_cowboy/_build/default/lib/cowboy/src/cowboy_stream_h.erl, 
> line 274)
>      ancestors: [<0.1022.0>,<0.407.0>,<0.406.0>,ranch_sup,<0.395.0>]
>      message_queue_len: 0
>      messages: []
>      links: [<0.1022.0>]
>      dictionary: []
>      trap_exit: false
>      status: running
>      heap_size: 1598
>      stack_size: 27
>      reductions: 770
>    neighbours:
> 
> 
> I have run out of options to triage this,trying to understand this 
> behavior.
> 
> Regards
> Maverick
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
> 

-- 
Loïc Hoguin
https://ninenines.eu



More information about the erlang-questions mailing list