You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by dr...@apache.org on 2008/07/16 07:13:31 UTC

svn commit: r677157 - /incubator/thrift/trunk/lib/erl/src/thrift_http_transport.erl

Author: dreiss
Date: Tue Jul 15 22:13:30 2008
New Revision: 677157

URL: http://svn.apache.org/viewvc?rev=677157&view=rev
Log:
THRIFT-83. erlang: Don't flush an empty buffer in the http transport.

Modified:
    incubator/thrift/trunk/lib/erl/src/thrift_http_transport.erl

Modified: incubator/thrift/trunk/lib/erl/src/thrift_http_transport.erl
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/erl/src/thrift_http_transport.erl?rev=677157&r1=677156&r2=677157&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/erl/src/thrift_http_transport.erl (original)
+++ incubator/thrift/trunk/lib/erl/src/thrift_http_transport.erl Tue Jul 15 22:13:30 2008
@@ -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.