rb: Support SSL and correct Content-Type in HTTPClient [THRIFT-156]

Author: Dave Engberg


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@704994 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/rb/lib/thrift/transport/httpclient.rb b/lib/rb/lib/thrift/transport/httpclient.rb
index 2c4adfc..cdfd26c 100644
--- a/lib/rb/lib/thrift/transport/httpclient.rb
+++ b/lib/rb/lib/thrift/transport/httpclient.rb
@@ -1,6 +1,7 @@
 require 'thrift/transport'
 
 require 'net/http'
+require 'net/https'
 require 'uri'
 require 'stringio'
 
@@ -17,7 +18,9 @@
     def write(buf); @outbuf << buf end
     def flush
       http = Net::HTTP.new @url.host, @url.port
-      resp, data = http.post(@url.path, @outbuf)
+      http.use_ssl = @url.scheme == "https"
+      headers = { 'Content-Type' => 'application/x-thrift' }
+      resp, data = http.post(@url.path, @outbuf, headers)
       @inbuf = StringIO.new data
       @outbuf = ""
     end