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 2009/03/30 22:47:01 UTC

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

Author: dreiss
Date: Mon Mar 30 20:47:01 2009
New Revision: 760165

URL: http://svn.apache.org/viewvc?rev=760165&view=rev
Log:
THRIFT-306. erlang: Let thrift_http_transport specify custom HTTP headers

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=760165&r1=760164&r2=760165&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/erl/src/thrift_http_transport.erl (original)
+++ incubator/thrift/trunk/lib/erl/src/thrift_http_transport.erl Mon Mar 30 20:47:01 2009
@@ -28,7 +28,8 @@
                          path, % string()
                          read_buffer, % iolist()
                          write_buffer, % iolist()
-                         http_options % see http(3)
+                         http_options, % see http(3)
+                         extra_headers % [{str(), str()}, ...]
                         }).
 
 %%====================================================================
@@ -99,11 +100,14 @@
                              path = Path,
                              read_buffer = [],
                              write_buffer = [],
-                             http_options = []},
+                             http_options = [],
+                             extra_headers = []},
     ApplyOption =
         fun
             ({http_options, HttpOpts}, State = #http_transport{}) ->
                 State#http_transport{http_options = HttpOpts};
+            ({extra_headers, ExtraHeaders}, State = #http_transport{}) ->
+                State#http_transport{extra_headers = ExtraHeaders};
             (Other, #http_transport{}) ->
                 {invalid_option, Other};
             (_, Error) ->
@@ -158,7 +162,8 @@
                                  path = Path,
                                  read_buffer = Rbuf,
                                  write_buffer = Wbuf,
-                                 http_options = HttpOptions}) ->
+                                 http_options = HttpOptions,
+                                 extra_headers = ExtraHeaders}) ->
     case iolist_to_binary(Wbuf) of
         <<>> ->
             %% Don't bother flushing empty buffers.
@@ -167,7 +172,7 @@
             {ok, {{_Version, 200, _ReasonPhrase}, _Headers, Body}} =
               http:request(post,
                            {"http://" ++ Host ++ Path,
-                            [{"User-Agent", "Erlang/thrift_http_transport"}],
+                            [{"User-Agent", "Erlang/thrift_http_transport"} | ExtraHeaders],
                             "application/x-thrift",
                             WBinary},
                            HttpOptions,