class WebSocket::HTTP::Request - websocket-driver-0.6.5 Documentation

# class WebSocket::HTTP::Request

### Constants

REQUEST_LINE
REQUEST_TARGET
RESERVED_HEADERS

### Attributes

env[R]

### Private Instance Methods

complete() click to toggle source
Calls superclass method WebSocket::HTTP::Headers#complete

    # File lib/websocket/http/request.rb, line 29
    def complete
      super
      @headers.each do |name, value|
        rack_name = name.upcase.gsub(/-/, '_')
        rack_name = "HTTP_#{rack_name}" unless RESERVED_HEADERS.include?(name)
        @env[rack_name] = value
      end
      if host = @env['HTTP_HOST']
        uri = URI.parse("http://#{host}")
        @env['SERVER_NAME'] = uri.host
        @env['SERVER_PORT'] = uri.port.to_s
      end
    end

start_line(line) click to toggle source

    # File lib/websocket/http/request.rb, line 15
    def start_line(line)
      return false unless parsed = line.scan(REQUEST_LINE).first

      target = parsed[1].scan(REQUEST_TARGET).first

      @env = {
        'REQUEST_METHOD' => parsed[0],
        'SCRIPT_NAME'    => '',
        'PATH_INFO'      => target[0],
        'QUERY_STRING'   => target[2] || ''
      }
      true
    end