THRIFT-811. rb: http_client_transport.rb: allow custom http headers

Allows setting of custom http headers in http_client_transport.rb 

Patch: Tony Kamenick

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@982804 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/rb/spec/http_client_spec.rb b/lib/rb/spec/http_client_spec.rb
index c5a9534..c919051 100644
--- a/lib/rb/spec/http_client_spec.rb
+++ b/lib/rb/spec/http_client_spec.rb
@@ -45,5 +45,20 @@
       @client.flush
       @client.read(10).should == "data"
     end
+
+    it "should send custom headers if defined" do
+      @client.write "test"
+      custom_headers = {"Cookie" => "Foo"}
+      headers = {"Content-Type"=>"application/x-thrift"}.merge(custom_headers)
+
+      @client.add_headers(custom_headers)
+      Net::HTTP.should_receive(:new).with("my.domain.com", 80).and_return do
+        mock("Net::HTTP").tee do |http|
+          http.should_receive(:use_ssl=).with(false)
+          http.should_receive(:post).with("/path/to/service?param=value", "test", headers).and_return([nil, "data"])
+        end
+      end
+      @client.flush
+    end
   end
 end