Sha256: 05b8f30329c63496046573d500031b063b1ff730fea5a412bbffc519fb3a9739

Contents?: true

Size: 901 Bytes

Versions: 10

Compression:

Stored size: 901 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 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

10 entries across 10 versions & 1 rubygems

Version Path
tingyun_rpm-1.2.0 lib/ting_yun/http/net_http_request.rb
tingyun_rpm-1.1.4.2 lib/ting_yun/http/net_http_request.rb
tingyun_rpm-1.1.4.1 lib/ting_yun/http/net_http_request.rb
tingyun_rpm-1.1.4 lib/ting_yun/http/net_http_request.rb
tingyun_rpm-1.1.3 lib/ting_yun/http/net_http_request.rb
tingyun_rpm-1.1.2 lib/ting_yun/http/net_http_request.rb
tingyun_rpm-1.1.1 lib/ting_yun/http/net_http_request.rb
tingyun_rpm-1.1.0 lib/ting_yun/http/net_http_request.rb
tingyun_rpm-1.0.7 lib/ting_yun/http/net_http_request.rb
tingyun_rpm-1.0.6 lib/ting_yun/http/net_http_request.rb