Sha256: 58ab34c651c5284d92e5ab830e6d71ccbaccaca4528690de528607eee162eb20

Contents?: true

Size: 948 Bytes

Versions: 4

Compression:

Stored size: 948 Bytes

Contents

require 'ting_yun/http/generic_request'
module TingYun
  module Http
    class NetHttpRequest < GenericRequest
      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

4 entries across 4 versions & 1 rubygems

Version Path
tingyun_rpm-1.4.2 lib/ting_yun/http/net_http_request.rb
tingyun_rpm-1.4.1 lib/ting_yun/http/net_http_request.rb
tingyun_rpm-1.3.1 lib/ting_yun/http/net_http_request.rb
tingyun_rpm-1.3.0 lib/ting_yun/http/net_http_request.rb