summaryrefslogtreecommitdiff
path: root/src/ibrowse
diff options
context:
space:
mode:
authorAdam Kocoloski <kocolosk@apache.org>2009-07-17 23:58:35 +0000
committerAdam Kocoloski <kocolosk@apache.org>2009-07-17 23:58:35 +0000
commit7264706c21a2533bc3244d01c168085614d13968 (patch)
treefe81b5d6f57700d485237d2e4f9b81c954084013 /src/ibrowse
parentf5d06318806e57f72ec88f1c27114db8d402c1e5 (diff)
update ibrowse to 1.5.1+
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@795278 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ibrowse')
-rw-r--r--src/ibrowse/ibrowse.app2
-rw-r--r--src/ibrowse/ibrowse.erl28
-rw-r--r--src/ibrowse/ibrowse_http_client.erl2
-rw-r--r--src/ibrowse/ibrowse_lb.erl8
-rw-r--r--src/ibrowse/ibrowse_lib.erl12
5 files changed, 34 insertions, 18 deletions
diff --git a/src/ibrowse/ibrowse.app b/src/ibrowse/ibrowse.app
index a3d23ae7..4f43dd92 100644
--- a/src/ibrowse/ibrowse.app
+++ b/src/ibrowse/ibrowse.app
@@ -1,6 +1,6 @@
{application, ibrowse,
[{description, "HTTP client application"},
- {vsn, "1.5.0"},
+ {vsn, "1.5.1"},
{modules, [ ibrowse,
ibrowse_http_client,
ibrowse_app,
diff --git a/src/ibrowse/ibrowse.erl b/src/ibrowse/ibrowse.erl
index 56f0ef4d..81fc74df 100644
--- a/src/ibrowse/ibrowse.erl
+++ b/src/ibrowse/ibrowse.erl
@@ -7,7 +7,7 @@
%%%-------------------------------------------------------------------
%% @author Chandrashekhar Mullaparthi <chandrashekhar dot mullaparthi at gmail dot com>
%% @copyright 2005-2009 Chandrashekhar Mullaparthi
-%% @version 1.5.0
+%% @version 1.5.1
%% @doc The ibrowse application implements an HTTP 1.1 client. This
%% module implements the API of the HTTP client. There is one named
%% process called 'ibrowse' which assists in load balancing and maintaining configuration. There is one load balancing process per unique webserver. There is
@@ -152,7 +152,7 @@ stop() ->
%% headerName() = string()
%% headerValue() = string()
%% response() = {ok, Status, ResponseHeaders, ResponseBody} | {ibrowse_req_id, req_id() } | {error, Reason}
-%% req_id = term()
+%% req_id() = term()
%% ResponseBody = string() | {file, Filename}
%% Reason = term()
send_req(Url, Headers, Method) ->
@@ -169,7 +169,7 @@ send_req(Url, Headers, Method, Body) ->
send_req(Url, Headers, Method, Body, []).
%% @doc Same as send_req/4.
-%% For a description of SSL Options, look in the ssl manpage. If the
+%% For a description of SSL Options, look in the <a href="http://www.erlang.org/doc/apps/ssl/index.html">ssl</a> manpage. If the
%% HTTP Version to use is not specified, the default is 1.1.
%% <br/>
%% <p>The <code>host_header</code> option is useful in the case where ibrowse is
@@ -181,7 +181,15 @@ send_req(Url, Headers, Method, Body) ->
%% used to specify what should go in the <code>Host</code> header in
%% the request.</p>
%% <ul>
-%% <li>When both the options <code>save_response_to_file</code> and <code>stream_to</code>
+%% <li>The <code>stream_to</code> option can be used to have the HTTP
+%% response streamed to a process as messages as data arrives on the
+%% socket. If the calling process wishes to control the rate at which
+%% data is received from the server, the option <code>{stream_to,
+%% {process(), once}}</code> can be specified. The calling process
+%% will have to invoke <code>ibrowse:stream_next(Request_id)</code> to
+%% receive the next packet.</li>
+%%
+%% <li>When both the options <code>save_response_to_file</code> and <code>stream_to</code>
%% are specified, the former takes precedence.</li>
%%
%% <li>For the <code>save_response_to_file</code> option, the response body is saved to
@@ -239,13 +247,14 @@ send_req(Url, Headers, Method, Body) ->
%% {content_length, integer()} |
%% {content_type, string()} |
%% {save_response_to_file, srtf()} |
-%% {stream_to, process()} |
+%% {stream_to, stream_to()} |
%% {http_vsn, {MajorVsn, MinorVsn}} |
%% {host_header, string()} |
%% {inactivity_timeout, integer()} |
%% {connect_timeout, integer()} |
%% {transfer_encoding, {chunked, ChunkSize}}
%%
+%% stream_to() = process() | {process(), once}
%% process() = pid() | atom()
%% username() = string()
%% password() = string()
@@ -363,10 +372,11 @@ do_send_req(Conn_Pid, Parsed_url, Headers, Method, Body, Options, Timeout) ->
Ret
end.
-ensure_bin(L) when is_list(L) ->
- list_to_binary(L);
-ensure_bin(B) when is_binary(B) ->
- B.
+ensure_bin(L) when is_list(L) -> list_to_binary(L);
+ensure_bin(B) when is_binary(B) -> B;
+ensure_bin(Fun) when is_function(Fun) -> Fun;
+ensure_bin({Fun}) when is_function(Fun) -> Fun;
+ensure_bin({Fun, _} = Body) when is_function(Fun) -> Body.
%% @doc Creates a HTTP client process to the specified Host:Port which
%% is not part of the load balancing pool. This is useful in cases
diff --git a/src/ibrowse/ibrowse_http_client.erl b/src/ibrowse/ibrowse_http_client.erl
index 43aa51f4..6a26dd4a 100644
--- a/src/ibrowse/ibrowse_http_client.erl
+++ b/src/ibrowse/ibrowse_http_client.erl
@@ -388,7 +388,7 @@ handle_sock_closed(#state{reply_buffer = Buf, reqs = Reqs, http_status_code = SC
case TmpFilename of
undefined ->
do_reply(State, From, StreamTo, ReqId, Resp_format,
- {ok, SC, Headers, lists:reverse(Buf)});
+ {ok, SC, Headers, Buf});
_ ->
file:close(Fd),
do_reply(State, From, StreamTo, ReqId, Resp_format,
diff --git a/src/ibrowse/ibrowse_lb.erl b/src/ibrowse/ibrowse_lb.erl
index b0654b72..9c2165b0 100644
--- a/src/ibrowse/ibrowse_lb.erl
+++ b/src/ibrowse/ibrowse_lb.erl
@@ -151,7 +151,13 @@ handle_info({'EXIT', Pid, _Reason},
ets:match_delete(Tid, {{'_', Pid}, '_'}),
{noreply, State#state{num_cur_sessions = Cur - 1}};
-handle_info({trace, Bool}, State) ->
+handle_info({trace, Bool}, #state{ets_tid = Tid} = State) ->
+ ets:foldl(fun({{_, Pid}, _}, Acc) when is_pid(Pid) ->
+ catch Pid ! {trace, Bool},
+ Acc;
+ (_, Acc) ->
+ Acc
+ end, undefined, Tid),
put(my_trace_flag, Bool),
{noreply, State};
diff --git a/src/ibrowse/ibrowse_lib.erl b/src/ibrowse/ibrowse_lib.erl
index 7567a6a6..6c7b1546 100644
--- a/src/ibrowse/ibrowse_lib.erl
+++ b/src/ibrowse/ibrowse_lib.erl
@@ -49,7 +49,7 @@ drv_ue(Str, Port) ->
%% @spec url_encode(Str) -> UrlEncodedStr
%% Str = string()
%% UrlEncodedStr = string()
-url_encode(Str) when list(Str) ->
+url_encode(Str) when is_list(Str) ->
url_encode_char(lists:reverse(Str), []).
url_encode_char([X | T], Acc) when X >= $0, X =< $9 ->
@@ -70,7 +70,7 @@ url_encode_char([], Acc) ->
d2h(N) when N<10 -> N+$0;
d2h(N) -> N+$a-10.
-decode_rfc822_date(String) when list(String) ->
+decode_rfc822_date(String) when is_list(String) ->
case catch decode_rfc822_date_1(string:tokens(String, ", \t\r\n")) of
{'EXIT', _} ->
{error, invalid_date};
@@ -177,9 +177,9 @@ dec2hex(M,N,Ack) -> dec2hex(M-1,N bsr 4,[d2h(N band 15)|Ack]).
%% @spec encode_base64(In) -> Out
%% In = string() | binary()
%% Out = string() | binary()
-encode_base64(List) when list(List) ->
+encode_base64(List) when is_list(List) ->
encode_base64_1(list_to_binary(List));
-encode_base64(Bin) when binary(Bin) ->
+encode_base64(Bin) when is_binary(Bin) ->
List = encode_base64_1(Bin),
list_to_binary(List).
@@ -197,9 +197,9 @@ encode_base64_1(<<>>) ->
%% @spec decode_base64(In) -> Out | exit({error, invalid_input})
%% In = string() | binary()
%% Out = string() | binary()
-decode_base64(List) when list(List) ->
+decode_base64(List) when is_list(List) ->
decode_base64_1(List, []);
-decode_base64(Bin) when binary(Bin) ->
+decode_base64(Bin) when is_binary(Bin) ->
List = decode_base64_1(binary_to_list(Bin), []),
list_to_binary(List).