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 3b9565c..80762d7 100644
--- a/lib/erl/src/thrift_http_transport.erl
+++ b/lib/erl/src/thrift_http_transport.erl
@@ -146,18 +146,24 @@
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}]),
+ 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}.
+ State1 = State#http_transport{read_buffer = [Rbuf, Body],
+ write_buffer = []},
+ {ok, State1}
+ end.
min(A,B) when A<B -> A;
min(_,B) -> B.