Sha256: 25d3088d0cd555a9393f225678ea710a8855b666b2c9ddcc411f13ab5f89c2e1

Contents?: true

Size: 950 Bytes

Versions: 2

Compression:

Stored size: 950 Bytes

Contents

require 'ting_yun/http/abstract_request'
module TingYun
  module Http
    class NetHttpRequest < AbstractRequest
      def initialize(connection, request)
        @connection = connection
        @request = request
      end

      def type
        'Net::HTTP'
      end

      def from
        "net%2Fhttp"
      end

      def host
        if hostname = self['host']
          hostname.split(':').first
        else
          @connection.address
        end
      end

      def method
        @request.method
      end

      def [](key)
        @request[key]
      end

      def []=(key, value)
        @request[key] = value
      end

      def uri
        case @request.path
          when /^https?:\/\//
            URI(@request.path)
          else
            scheme = @connection.use_ssl? ? 'https' : 'http'
            URI("#{scheme}://#{@connection.address}:#{@connection.port}#{@request.path}")
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tingyun_rpm-1.6.1 lib/ting_yun/http/net_http_request.rb
tingyun_rpm-1.5.0 lib/ting_yun/http/net_http_request.rb