require 'thrift/transport'

require 'net/http'
require 'uri'
require 'stringio'

## Very simple HTTP client
module Thrift
  class HTTPClient < Transport
    def initialize(url)
      @url = URI url
      @outbuf = ""
    end

    def open?; true end
    def read(sz); @inbuf.read sz end
    def write(buf); @outbuf << buf end
    def flush
      http = Net::HTTP.new @url.host, @url.port
      resp, data = http.post(@url.path, @outbuf)
      @inbuf = StringIO.new data
      @outbuf = ""
    end
  end
  deprecate_class! :THttpClient => HTTPClient
end

require 'thrift/transport'

require 'net/http'
require 'net/https'
require 'uri'
require 'stringio'

## Very simple HTTP client
module Thrift
  class HTTPClient < Transport
    def initialize(url)
      @url = URI url
      @outbuf = ""
    end

    def open?; true end
    def read(sz); @inbuf.read sz end
    def write(buf); @outbuf << buf end
    def flush
      http = Net::HTTP.new @url.host, @url.port
      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
  end
  deprecate_class! :THttpClient => HTTPClient
end

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

Author: Dave Engberg


git-svn-id: 8d8e29b1fb681c884914062b88f3633e3a187774@704994 13f79535-47bb-0310-9956-ffa450edef68
