You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2014/02/12 07:21:13 UTC

[24/33] ibrowse commit: updated refs/heads/import-master to 1167b0e

Yet another ibrowse fix.
Patch submitted upstream:  https://github.com/cmullaparthi/ibrowse/issues/issue/20



git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@1034404 13f79535-47bb-0310-9956-ffa450edef68


Project: http://git-wip-us.apache.org/repos/asf/couchdb-ibrowse/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-ibrowse/commit/8f3735f0
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-ibrowse/tree/8f3735f0
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-ibrowse/diff/8f3735f0

Branch: refs/heads/import-master
Commit: 8f3735f01063758ebfdc3c8c6919c87d33f1f27f
Parents: 0db80d3
Author: Filipe David Borba Manana <fd...@apache.org>
Authored: Fri Nov 12 14:29:00 2010 +0000
Committer: Filipe David Borba Manana <fd...@apache.org>
Committed: Fri Nov 12 14:29:00 2010 +0000

----------------------------------------------------------------------
 ibrowse_http_client.erl | 10 +++++-----
 ibrowse_lib.erl         | 12 ++++--------
 2 files changed, 9 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-ibrowse/blob/8f3735f0/ibrowse_http_client.erl
----------------------------------------------------------------------
diff --git a/ibrowse_http_client.erl b/ibrowse_http_client.erl
index 5c3d5c9..5ff323c 100644
--- a/ibrowse_http_client.erl
+++ b/ibrowse_http_client.erl
@@ -544,7 +544,7 @@ do_send_body1(Source, Resp, State, TE) ->
 maybe_chunked_encode(Data, false) ->
     Data;
 maybe_chunked_encode(Data, true) ->
-    [ibrowse_lib:dec2hex(4, size(to_binary(Data))), "\r\n", Data, "\r\n"].
+    [ibrowse_lib:dec2hex(byte_size(to_binary(Data))), "\r\n", Data, "\r\n"].
 
 do_close(#state{socket = undefined})            ->  ok;
 do_close(#state{socket = Sock,
@@ -927,23 +927,23 @@ chunk_request_body(Body, _ChunkSize, Acc) when Body == <<>>; Body == [] ->
 chunk_request_body(Body, ChunkSize, Acc) when is_binary(Body),
                                               size(Body) >= ChunkSize ->
     <<ChunkBody:ChunkSize/binary, Rest/binary>> = Body,
-    Chunk = [ibrowse_lib:dec2hex(4, ChunkSize),"\r\n",
+    Chunk = [ibrowse_lib: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(4, BodySize),"\r\n",
+    Chunk = [ibrowse_lib: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(4, ChunkSize),"\r\n",
+    Chunk = [ibrowse_lib: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(4, BodySize),"\r\n",
+    Chunk = [ibrowse_lib:dec2hex(BodySize),"\r\n",
              Body, "\r\n"],
     LastChunk = "0\r\n",
     lists:reverse(["\r\n", LastChunk, Chunk | Acc]).

http://git-wip-us.apache.org/repos/asf/couchdb-ibrowse/blob/8f3735f0/ibrowse_lib.erl
----------------------------------------------------------------------
diff --git a/ibrowse_lib.erl b/ibrowse_lib.erl
index c463c7b..e913adb 100644
--- a/ibrowse_lib.erl
+++ b/ibrowse_lib.erl
@@ -19,7 +19,7 @@
          url_encode/1,
          decode_rfc822_date/1,
          status_code/1,
-         dec2hex/2,
+         dec2hex/1,
          drv_ue/1,
          drv_ue/2,
          encode_base64/1,
@@ -163,14 +163,10 @@ status_code(507) -> insufficient_storage;
 status_code(X) when is_list(X) -> status_code(list_to_integer(X));
 status_code(_)   -> unknown_status_code.
 
-%% @doc dec2hex taken from gtk.erl in std dist
-%% M = integer() -- number of hex digits required
+%% @doc Returns a string with the hexadecimal representation of a given decimal.
 %% N = integer() -- the number to represent as hex
-%% @spec dec2hex(M::integer(), N::integer()) -> string()
-dec2hex(M,N) -> dec2hex(M,N,[]).
-
-dec2hex(0,_N,Ack) -> Ack;
-dec2hex(M,N,Ack) -> dec2hex(M-1,N bsr 4,[d2h(N band 15)|Ack]).
+%% @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