httpc pipeline problem.

Wilson Tam wilson.sh.tam@REDACTED
Mon Oct 3 09:24:40 CEST 2005


Hi,

I recently upgrade my Erlang to R10B-7 with inet-4.5.1.

The http:request pipeline seems not working with 'post' mode. For  
'get' is fine.  I have written a small problem to show the problem.

After run the program and read the log from my Apache log. I saw  
that, 'get' is reusing the connection. But 'post' is not.

Can anyone help? Thanks.
- wilson

== code =======
-module(testpipeline).
-behaviour(gen_server).
-export([start_link/1]).
-export([init/1, handle_call/3, handle_cast/2, handle_info/2]).
-export([code_change/3, terminate/2]).
-define(HOWALL_INTERVAL, 500).

start_link(Url) ->
     gen_server:start_link({local, testpipeline}, testpipeline,  
[Url], []).

init(Url) ->
     timer:send_after(2000, poll),
     http:set_options([{pipeline_timeout, 60000000}, {max_sessions,  
10}]),
     {ok, Url}.

terminate(_, _State) ->
     ok.

code_change(_OldVsn, State, _Extra) ->
     {ok, State}.

handle_call(_, _, State) ->
     {reply, ok, State}.

handle_cast(_, _S) ->
     {noreply, _S}.

handle_info(poll, S) ->
     testpost(S),
     testget(S),
     timer:send_after(2000, poll),
     {noreply, S}.


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
testpost([S]) ->
     case http:request(post, {S, [], "application/x-www-form- 
urlencoded", []}, [], []) of
     {ok, {{_Version, _Code, _ReasonPhrase}, _Headers, Body}} ->
         io:format("~p~n", [Body]);
     {error, Reason} ->
         io:format("Error: ~p~n", [Reason])
     end.

testget([S]) ->
     case http:request(get, {S, []}, [], []) of
     {ok, {{_Version, _Code, _ReasonPhrase}, _Headers, Body}} ->
         io:format("~p~n", [Body]);
     {error, Reason} ->
         io:format("Error: ~p~n", [Reason])
     end.

== code end ===



More information about the erlang-questions mailing list