Weird problem when using tcp sockets in HTTP mode

Mihai Balea mihai@REDACTED
Fri Jul 17 23:22:40 CEST 2009


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



More information about the erlang-questions mailing list