You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by jk...@apache.org on 2017/09/26 13:42:42 UTC

thrift git commit: THRIFT-4348 - Allow custom HTTP headers to be set in Perl HTTP client. Client: Perl

Repository: thrift
Updated Branches:
  refs/heads/master 2d1fe88db -> d7720f436


THRIFT-4348 - Allow custom HTTP headers to be set in Perl HTTP client.
Client: Perl

This closes #1376


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/d7720f43
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/d7720f43
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/d7720f43

Branch: refs/heads/master
Commit: d7720f43632f004df09686faa2f238bcc7f1f706
Parents: 2d1fe88
Author: Carwyn Moore <ca...@modicagroup.com>
Authored: Tue Sep 26 16:38:57 2017 +1300
Committer: James E. King, III <jk...@apache.org>
Committed: Tue Sep 26 06:42:14 2017 -0700

----------------------------------------------------------------------
 lib/perl/lib/Thrift/HttpClient.pm | 10 ++++++++++
 1 file changed, 10 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/d7720f43/lib/perl/lib/Thrift/HttpClient.pm
----------------------------------------------------------------------
diff --git a/lib/perl/lib/Thrift/HttpClient.pm b/lib/perl/lib/Thrift/HttpClient.pm
index 2ad618f..6e6a631 100644
--- a/lib/perl/lib/Thrift/HttpClient.pm
+++ b/lib/perl/lib/Thrift/HttpClient.pm
@@ -45,6 +45,7 @@ sub new
         out          => $out,
         timeout      => 100,
         handle       => undef,
+        headers      => {},
     };
 
     return bless($self,$classname);
@@ -74,6 +75,14 @@ sub setSendTimeout
     $self->setTimeout($timeout);
 }
 
+sub setHeader
+{
+    my $self = shift;
+    my ($name, $value) = @_;
+
+    $self->{headers}->{$name} = $value;
+}
+
 #
 # Tests whether this is open
 #
@@ -176,6 +185,7 @@ sub flush
     my $buf = join('', <$out>);
 
     my $request = new HTTP::Request(POST => $self->{url}, undef, $buf);
+    map { $request->header($_ => $self->{headers}->{$_}) } keys %{$self->{headers}};
     my $response = $ua->request($request);
     my $content_ref = $response->content_ref;