[erlang-questions] Problem of post the data with httpc

Robert Raschke rtrlists@REDACTED
Tue May 27 17:06:36 CEST 2014


Hi Solomon,

I think you're just missing the Content-Length header. And for real work,
you'll also want to pass in the Content-Type. Also, if I remember
correctly, the parse_post function expects x-www-form-urlencoded data in
the body, whereas recv_body just gives you whatever is there as a binary.

Robby
 On May 27, 2014 11:05 AM, "Solomon" <solomon.wzs@REDACTED> wrote:

> Hi.
>
> When I use curl post the data to mochiweb like this:
>
> curl http://192.168.1.1 -d "hello"
>
> I could call Req:parse_post() to get the data like [{"hello",[]}], and
> call Req:recv_body() to get the data like <<"hello">>.
>
> When I use httpc post the data to mochiweb like this:
>
> httpc:request(post, {"http://192.168.1..1", [], [], "hello"}, [], [])
>
> I could call Req:recv_body() to get the data like <<"hello">>, but when I
> call Req:parse_post(), it return [].
>
> How should I post data with httpc like curl?
>
> Regards,
> Solomon
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20140527/b8263931/attachment.htm>


More information about the erlang-questions mailing list