Patch to Ruby HTTPClient to support SSL and to send correct Thrift Content-Type 
header
--------------------------------------------------------------------------------------

                 Key: THRIFT-156
                 URL: https://issues.apache.org/jira/browse/THRIFT-156
             Project: Thrift
          Issue Type: Bug
          Components: Library (Ruby)
            Reporter: Dave Engberg
         Attachments: httpclient.rb.diff

The Ruby HTTPClient class fails if you provide an https: URL, and it does not 
set the same HTTP Content-Type header as the other language libraries.

This small patch addresses these two issues:

Index: lib/rb/lib/thrift/transport/httpclient.rb
===================================================================
--- lib/rb/lib/thrift/transport/httpclient.rb   (revision 701711)
+++ lib/rb/lib/thrift/transport/httpclient.rb   (working copy)
@@ -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


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to