From: David Reiss Date: Wed, 16 Jul 2008 05:13:30 +0000 (+0000) Subject: THRIFT-83. erlang: Don't flush an empty buffer in the http transport. X-Git-Tag: 0.2.0~470 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=7a4ff6be4d7ce6726bcd4573a00669678697f1d9;p=common%2Fthrift.git THRIFT-83. erlang: Don't flush an empty buffer in the http transport. git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@677157 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/lib/erl/src/thrift_http_transport.erl b/lib/erl/src/thrift_http_transport.erl index 3b9565cf..80762d70 100644 --- a/lib/erl/src/thrift_http_transport.erl +++ b/lib/erl/src/thrift_http_transport.erl @@ -146,18 +146,24 @@ do_flush(State = #http_transport{host = Host, read_buffer = Rbuf, write_buffer = Wbuf, http_options = HttpOptions}) -> - {ok, {{_Version, 200, _ReasonPhrase}, _Headers, Body}} = - http:request(post, - {"http://" ++ Host ++ Path, - [{"User-Agent", "Erlang/thrift_http_transport"}], - "application/x-thrift", - iolist_to_binary(Wbuf)}, - HttpOptions, - [{body_format, binary}]), - - State1 = State#http_transport{read_buffer = [Rbuf, Body], - write_buffer = []}, - {ok, State1}. + case iolist_to_binary(Wbuf) of -> + <<>> -> + %% Don't bother flushing empty buffers. + {ok, State}; + WBinary -> + {ok, {{_Version, 200, _ReasonPhrase}, _Headers, Body}} = + http:request(post, + {"http://" ++ Host ++ Path, + [{"User-Agent", "Erlang/thrift_http_transport"}], + "application/x-thrift", + WBinary}, + HttpOptions, + [{body_format, binary}]), + + State1 = State#http_transport{read_buffer = [Rbuf, Body], + write_buffer = []}, + {ok, State1} + end. min(A,B) when A A; min(_,B) -> B.