From: Kevin Clark Date: Wed, 15 Oct 2008 19:06:18 +0000 (+0000) Subject: rb: Support SSL and correct Content-Type in HTTPClient [THRIFT-156] X-Git-Tag: 0.2.0~429 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=c2485608976036d50b0066018f8d3dbb80291f6c;p=common%2Fthrift.git 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 2c4adfcd..cdfd26cd 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 @@ 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