[erlang-questions] Weird problem when using tcp sockets in HTTP mode

Christian chsu79@REDACTED
Sat Jul 18 00:36:00 CEST 2009


Did you try to quote the url when you pass it to curl? The shell
probably tries to interpret ampersand to make it a background job.

Otherwise, use wireshark and get the facts about what requests are sent.


On Fri, Jul 17, 2009 at 23:22, Mihai Balea<mihai@REDACTED> wrote:
> Hi all,
>
> I'm hitting a weird problem and I'm wondering if it is a bug somewhere in
> the system libs.
>
> I'm running R13B01. I am opening a tcp socket in http mode and apparently
> the HttpUri returned by gen_tcp:recv contains only the first key-value pair
> of the query string.
>
> Here's the code I'm running:
>
> -module(h).
> -compile(export_all).
>
> run() ->
>    {ok, LS} = gen_tcp:listen(6969, [{packet, http}, {active, false},
> {reuseaddr, true}, list]),
>    {ok, S} = gen_tcp:accept(LS),
>    do_recv(S).
>
> do_recv(S) ->
>    {ok, Packet} = gen_tcp:recv(S, 0),
>    io:format("~p\n", [Packet]),
>    do_recv(S).
>
> Here's the query:
> curl -v http://localhost:6969/foo/bar?a=1&b=2&c=3
>
> And the output of the program:
> 3> h:run().
> {http_request,'GET',{abs_path,"/foo/bar?a=1"},{1,1}}
> {http_header,24,'User-Agent',undefined,
>             "curl/7.19.5 (i386-apple-darwin9.7.0) libcurl/7.19.5
> zlib/1.2.3"}
> {http_header,14,'Host',undefined,"localhost:6969"}
> {http_header,8,'Accept',undefined,"*/*"}
> http_eoh
>
> Am I doing something wrong or is this indeed a bug?
>
> Thanks,
> Mihai
>
>
> ________________________________________________________________
> erlang-questions mailing list. See http://www.erlang.org/faq.html
> erlang-questions (at) erlang.org
>
>


More information about the erlang-questions mailing list