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/11/04 23:24:33 UTC
svn commit: r1031297 -
/couchdb/branches/new_replicator/src/couchdb/couch_api_wrap_httpc.erl
Author: fdmanana
Date: Thu Nov 4 22:24:33 2010
New Revision: 1031297
URL: http://svn.apache.org/viewvc?rev=1031297&view=rev
Log:
New replicator: make sure put and post requests without a body have a Content-Length header with value 0.
Modified:
couchdb/branches/new_replicator/src/couchdb/couch_api_wrap_httpc.erl
Modified: couchdb/branches/new_replicator/src/couchdb/couch_api_wrap_httpc.erl
URL: http://svn.apache.org/viewvc/couchdb/branches/new_replicator/src/couchdb/couch_api_wrap_httpc.erl?rev=1031297&r1=1031296&r2=1031297&view=diff
==============================================================================
--- couchdb/branches/new_replicator/src/couchdb/couch_api_wrap_httpc.erl (original)
+++ couchdb/branches/new_replicator/src/couchdb/couch_api_wrap_httpc.erl Thu Nov 4 22:24:33 2010
@@ -34,16 +34,24 @@ send_req(#httpdb{headers = BaseHeaders}
Else ->
{Else, Headers1}
end,
+ Headers2 = case {Method, Body} of
+ {put, []} ->
+ lists:keystore("Content-Length", 1, Headers, {"Content-Length", 0});
+ {post, []} ->
+ lists:keystore("Content-Length", 1, Headers, {"Content-Length", 0});
+ _ ->
+ Headers
+ end,
IbrowseOptions = [
{response_format, binary}, {inactivity_timeout, HttpDb#httpdb.timeout},
{socket_options, [{reuseaddr, true}, {keepalive, true}]}
| get_value(ibrowse_options, Params, []) ++ HttpDb#httpdb.proxy_options
],
- Headers2 = oauth_header(HttpDb, Params) ++ BaseHeaders ++ Headers,
+ Headers3 = oauth_header(HttpDb, Params) ++ BaseHeaders ++ Headers2,
Url = full_url(HttpDb, Params),
{ok, Worker} = ibrowse:spawn_link_worker_process(Url),
Response = ibrowse:send_req_direct(
- Worker, Url, Headers2, Method, Body, IbrowseOptions, infinity),
+ Worker, Url, Headers3, Method, Body, IbrowseOptions, infinity),
process_response(Response, Worker, HttpDb, Params, Callback).