rb: Support SSL and correct Content-Type in HTTPClient [THRIFT-156]
authorKevin Clark <kclark@apache.org>
Wed, 15 Oct 2008 19:06:18 +0000 (19:06 +0000)
committerKevin Clark <kclark@apache.org>
Wed, 15 Oct 2008 19:06:18 +0000 (19:06 +0000)
Author: Dave Engberg

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@704994 13f79535-47bb-0310-9956-ffa450edef68

lib/rb/lib/thrift/transport/httpclient.rb

index 2c4adfc..cdfd26c 100644 (file)
@@ -1,6 +1,7 @@
 require 'thrift/transport'
 
 require 'net/http'
+require 'net/https'
 require 'uri'
 require 'stringio'
 
@@ -17,7 +18,9 @@ module Thrift
     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