Sha256: 29ca10b1dda9eec229d00fc5b6604d7ce3f7ed09f78f51e1b4689697b50c8a67

Contents?: true

Size: 1.02 KB

Versions: 9

Compression:

Stored size: 1.02 KB

Contents

module Reel
  module HTTPVersionsMixin

    HTTP_VERSION_1_0     = '1.0'.freeze
    HTTP_VERSION_1_1     = '1.1'.freeze
    DEFAULT_HTTP_VERSION = HTTP_VERSION_1_1
  end

  module ConnectionMixin

    # Obtain the IP address of the remote connection
    def remote_ip
      socket.peeraddr(false)[3]
    end
    alias remote_addr remote_ip

    # Obtain the hostname of the remote connection
    def remote_host
      # NOTE: Celluloid::IO does not yet support non-blocking reverse DNS
      socket.peeraddr(true)[2]
    end

  end

  module RequestMixin

    def method
      @request_info.http_method
    end

    def headers
      @request_info.headers
    end

    def [](header)
      headers[header]
    end

    def version
      @request_info.http_version || HTTPVersionsMixin::DEFAULT_HTTP_VERSION
    end

    def url
      @request_info.url
    end

    def uri
      @uri ||= URI(url)
    end

    def path
      uri.path
    end

    def query_string
      uri.query
    end

    def fragment
      uri.fragment
    end

  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
reel-0.6.1 lib/reel/mixins.rb
reel-0.6.0 lib/reel/mixins.rb
reel-0.6.0.pre5 lib/reel/mixins.rb
reel-0.6.0.pre4 lib/reel/mixins.rb
reel-0.6.0.pre3 lib/reel/mixins.rb
reel-0.6.0.pre2 lib/reel/mixins.rb
reel-0.6.0.pre1 lib/reel/mixins.rb
reel-0.5.0 lib/reel/mixins.rb
reel-0.5.0.pre lib/reel/mixins.rb