<p>Hi Solomon,</p>
<p>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.</p>
<p>Robby<br>
</p>
<div class="gmail_quote">On May 27, 2014 11:05 AM, "Solomon" <<a href="mailto:solomon.wzs@gmail.com">solomon.wzs@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Hi.<br><br>When I use curl post the data to mochiweb like this:<br><br>curl <a href="http://192.168.1.1" target="_blank">http://192.168.1.1</a> -d "hello"<br><br>I could call Req:parse_post() to get the data like [{"hello",[]}], and call Req:recv_body() to get the data like <<"hello">>.<br>
<br>When I use httpc post the data to mochiweb like this:<br><br>httpc:request(post, {"<a href="http://192.168.1." target="_blank">http://192.168.1.</a>.1", [], [], "hello"}, [], [])<br><br>I could call Req:recv_body() to get the data like <<"hello">>, but when I call Req:parse_post(), it return [].<br>
<br>How should I post data with httpc like curl?<br><br>Regards,<br>Solomon<br></div>
<br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div>