You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by fd...@apache.org on 2010/12/18 14:25:15 UTC

svn commit: r1050635 - in /couchdb/branches/1.0.x/src/ibrowse: Makefile.am ibrowse.app.in ibrowse.erl ibrowse_http_client.erl ibrowse_lib.erl

Author: fdmanana
Date: Sat Dec 18 13:25:14 2010
New Revision: 1050635

URL: http://svn.apache.org/viewvc?rev=1050635&view=rev
Log:
Merged revision 1050633 from trunk

Upgrade ibrowse to version 2.1.1

This ibrowse release includes a few important fixes.
See https://github.com/cmullaparthi/ibrowse for the list of fixes.


Modified:
    couchdb/branches/1.0.x/src/ibrowse/Makefile.am
    couchdb/branches/1.0.x/src/ibrowse/ibrowse.app.in
    couchdb/branches/1.0.x/src/ibrowse/ibrowse.erl
    couchdb/branches/1.0.x/src/ibrowse/ibrowse_http_client.erl
    couchdb/branches/1.0.x/src/ibrowse/ibrowse_lib.erl

Modified: couchdb/branches/1.0.x/src/ibrowse/Makefile.am
URL: http://svn.apache.org/viewvc/couchdb/branches/1.0.x/src/ibrowse/Makefile.am?rev=1050635&r1=1050634&r2=1050635&view=diff
==============================================================================
--- couchdb/branches/1.0.x/src/ibrowse/Makefile.am (original)
+++ couchdb/branches/1.0.x/src/ibrowse/Makefile.am Sat Dec 18 13:25:14 2010
@@ -10,7 +10,7 @@
 ## License for the specific language governing permissions and limitations under
 ## the License.
 
-ibrowseebindir = $(localerlanglibdir)/ibrowse-2.1.0/ebin
+ibrowseebindir = $(localerlanglibdir)/ibrowse-2.1.1/ebin
 
 ibrowse_file_collection = \
 	ibrowse.app.in \

Modified: couchdb/branches/1.0.x/src/ibrowse/ibrowse.app.in
URL: http://svn.apache.org/viewvc/couchdb/branches/1.0.x/src/ibrowse/ibrowse.app.in?rev=1050635&r1=1050634&r2=1050635&view=diff
==============================================================================
--- couchdb/branches/1.0.x/src/ibrowse/ibrowse.app.in (original)
+++ couchdb/branches/1.0.x/src/ibrowse/ibrowse.app.in Sat Dec 18 13:25:14 2010
@@ -1,6 +1,6 @@
 {application, ibrowse,
         [{description, "HTTP client application"},
-         {vsn, "2.1.0"},
+         {vsn, "2.1.1"},
          {modules, [ ibrowse, 
 		     ibrowse_http_client, 
 		     ibrowse_app, 

Modified: couchdb/branches/1.0.x/src/ibrowse/ibrowse.erl
URL: http://svn.apache.org/viewvc/couchdb/branches/1.0.x/src/ibrowse/ibrowse.erl?rev=1050635&r1=1050634&r2=1050635&view=diff
==============================================================================
--- couchdb/branches/1.0.x/src/ibrowse/ibrowse.erl (original)
+++ couchdb/branches/1.0.x/src/ibrowse/ibrowse.erl Sat Dec 18 13:25:14 2010
@@ -7,7 +7,7 @@
 %%%-------------------------------------------------------------------
 %% @author Chandrashekhar Mullaparthi <chandrashekhar dot mullaparthi at gmail dot com>
 %% @copyright 2005-2010 Chandrashekhar Mullaparthi
-%% @version 2.1.0
+%% @version 2.1.1
 %% @doc The ibrowse application implements an HTTP 1.1 client in erlang. 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

Modified: couchdb/branches/1.0.x/src/ibrowse/ibrowse_http_client.erl
URL: http://svn.apache.org/viewvc/couchdb/branches/1.0.x/src/ibrowse/ibrowse_http_client.erl?rev=1050635&r1=1050634&r2=1050635&view=diff
==============================================================================
--- couchdb/branches/1.0.x/src/ibrowse/ibrowse_http_client.erl (original)
+++ couchdb/branches/1.0.x/src/ibrowse/ibrowse_http_client.erl Sat Dec 18 13:25:14 2010
@@ -69,7 +69,7 @@
                      ]).
 
 -define(DEFAULT_STREAM_CHUNK_SIZE, 1024*1024).
-
+-define(dec2hex(X), erlang:integer_to_list(X, 16)).
 %%====================================================================
 %% External functions
 %%====================================================================
@@ -197,7 +197,7 @@ handle_info({stream_close, _Req_id}, Sta
     shutting_down(State),
     do_close(State),
     do_error_reply(State, closing_on_request),
-    {stop, normal, ok, State};
+    {stop, normal, State};
 
 handle_info({tcp_closed, _Sock}, State) ->    
     do_trace("TCP connection closed by peer!~n", []),
@@ -369,15 +369,6 @@ accumulate_response(Data, #state{cur_req
         {error, Reason} ->
             {error, {file_write_error, Reason}}
     end;
-%% accumulate_response(<<>>, #state{cur_req = #request{caller_controls_socket = Ccs},
-%%                                  socket = Socket} = State) ->
-%%     case Ccs of
-%%         true ->
-%%             do_setopts(Socket, [{active, once}], State);
-%%         false ->
-%%             ok
-%%     end,
-%%     State;
 accumulate_response(Data, #state{reply_buffer      = RepBuf,
                                  rep_buf_size      = RepBufSize,
                                  streamed_size     = Streamed_size,
@@ -544,7 +535,7 @@ do_send_body1(Source, Resp, State, TE) -
 maybe_chunked_encode(Data, false) ->
     Data;
 maybe_chunked_encode(Data, true) ->
-    [ibrowse_lib:dec2hex(byte_size(to_binary(Data))), "\r\n", Data, "\r\n"].
+    [?dec2hex(size(to_binary(Data))), "\r\n", Data, "\r\n"].
 
 do_close(#state{socket = undefined})            ->  ok;
 do_close(#state{socket = Sock,
@@ -683,8 +674,7 @@ send_req_1(From,
                 path    = RelPath} = Url,
            Headers, Method, Body, Options, Timeout,
            #state{status    = Status,
-                  socket    = Socket,
-                  is_ssl    = Is_ssl} = State) ->
+                  socket    = Socket} = State) ->
     ReqId = make_req_id(),
     Resp_format = get_value(response_format, Options, list),
     Caller_socket_options = get_value(socket_options, Options, []),
@@ -723,7 +713,7 @@ send_req_1(From,
                                  Headers_1,
                                  AbsPath, RelPath, Body, Options, State_1),
     trace_request(Req),
-    do_setopts(Socket, Caller_socket_options, Is_ssl),
+    do_setopts(Socket, Caller_socket_options, State_1),
     TE = is_chunked_encoding_specified(Options),
     case do_send(Req, State_1) of
         ok ->
@@ -831,17 +821,14 @@ make_request(Method, Headers, AbsPath, R
     Headers_0 = [Fun1(X) || X <- Headers],
     Headers_1 =
         case lists:keysearch("content-length", 1, Headers_0) of
-            false when (Body == []) orelse
-                       (Body == <<>>) orelse
-                       is_tuple(Body) orelse
-                       is_function(Body) ->
-                Headers_0;
-            false when is_binary(Body) ->
-                [{"content-length", "content-length", integer_to_list(size(Body))} | Headers_0];
-            false when is_list(Body) ->
-                [{"content-length", "content-length", integer_to_list(length(Body))} | Headers_0];
+            false when (Body =:= [] orelse Body =:= <<>>) andalso
+                       (Method =:= post orelse Method =:= put) ->
+                [{"content-length", "Content-Length", "0"} | Headers_0];
+            false when is_binary(Body) orelse is_list(Body) ->
+                [{"content-length", "Content-Length", integer_to_list(iolist_size(Body))} | Headers_0];
             _ ->
-                %% Content-Length is already specified
+                %% Content-Length is already specified or Body is a
+                %% function or function/state pair
                 Headers_0
         end,
     {Headers_2, Body_1} =
@@ -927,23 +914,23 @@ chunk_request_body(Body, _ChunkSize, Acc
 chunk_request_body(Body, ChunkSize, Acc) when is_binary(Body),
                                               size(Body) >= ChunkSize ->
     <<ChunkBody:ChunkSize/binary, Rest/binary>> = Body,
-    Chunk = [ibrowse_lib:dec2hex(ChunkSize),"\r\n",
+    Chunk = [?dec2hex(ChunkSize),"\r\n",
              ChunkBody, "\r\n"],
     chunk_request_body(Rest, ChunkSize, [Chunk | Acc]);
 chunk_request_body(Body, _ChunkSize, Acc) when is_binary(Body) ->
     BodySize = size(Body),
-    Chunk = [ibrowse_lib:dec2hex(BodySize),"\r\n",
+    Chunk = [?dec2hex(BodySize),"\r\n",
              Body, "\r\n"],
     LastChunk = "0\r\n",
     lists:reverse(["\r\n", LastChunk, Chunk | Acc]);
 chunk_request_body(Body, ChunkSize, Acc) when length(Body) >= ChunkSize ->
     {ChunkBody, Rest} = split_list_at(Body, ChunkSize),
-    Chunk = [ibrowse_lib:dec2hex(ChunkSize),"\r\n",
+    Chunk = [?dec2hex(ChunkSize),"\r\n",
              ChunkBody, "\r\n"],
     chunk_request_body(Rest, ChunkSize, [Chunk | Acc]);
 chunk_request_body(Body, _ChunkSize, Acc) when is_list(Body) ->
     BodySize = length(Body),
-    Chunk = [ibrowse_lib:dec2hex(BodySize),"\r\n",
+    Chunk = [?dec2hex(BodySize),"\r\n",
              Body, "\r\n"],
     LastChunk = "0\r\n",
     lists:reverse(["\r\n", LastChunk, Chunk | Acc]).

Modified: couchdb/branches/1.0.x/src/ibrowse/ibrowse_lib.erl
URL: http://svn.apache.org/viewvc/couchdb/branches/1.0.x/src/ibrowse/ibrowse_lib.erl?rev=1050635&r1=1050634&r2=1050635&view=diff
==============================================================================
--- couchdb/branches/1.0.x/src/ibrowse/ibrowse_lib.erl (original)
+++ couchdb/branches/1.0.x/src/ibrowse/ibrowse_lib.erl Sat Dec 18 13:25:14 2010
@@ -19,9 +19,6 @@
          url_encode/1,
          decode_rfc822_date/1,
          status_code/1,
-         dec2hex/1,
-         drv_ue/1,
-         drv_ue/2,
          encode_base64/1,
          decode_base64/1,
          get_value/2,
@@ -33,17 +30,6 @@
 get_trace_status(Host, Port) ->
     ibrowse:get_config_value({trace, Host, Port}, false).
 
-drv_ue(Str) ->
-    [{port, Port}| _] = ets:lookup(ibrowse_table, port),
-    drv_ue(Str, Port).
-drv_ue(Str, Port) ->
-    case erlang:port_control(Port, 1, Str) of
-        [] ->
-            Str;
-        Res ->
-            Res
-    end.
-
 %% @doc URL-encodes a string based on RFC 1738. Returns a flat list.
 %% @spec url_encode(Str) -> UrlEncodedStr
 %% Str = string()
@@ -163,11 +149,6 @@ status_code(507) -> insufficient_storage
 status_code(X) when is_list(X) -> status_code(list_to_integer(X));
 status_code(_)   -> unknown_status_code.
 
-%% @doc Returns a string with the hexadecimal representation of a given decimal.
-%% N = integer() -- the number to represent as hex
-%% @spec dec2hex(N::integer()) -> string()
-dec2hex(N) -> lists:flatten(io_lib:format("~.16B", [N])).
-
 %% @doc Implements the base64 encoding algorithm. The output data type matches in the input data type.
 %% @spec encode_base64(In) -> Out
 %% In = string() | binary()