Class: EventParsers::Http11Parser::Request

Inherits:
Object
  • Object
show all
Defined in:
bin/httphere

Direct Known Subclasses

FileServer

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_params = {}) ⇒ Request

Returns a new instance of Request.



371
372
373
374
375
376
377
378
379
# File 'bin/httphere', line 371

def initialize(request_params={})
  @http_version = request_params[:http_version] if request_params.has_key? :http_version
  @resource_uri = request_params[:resource_uri] if request_params.has_key? :resource_uri
  @headers      = request_params[:headers] if request_params.has_key? :headers
  @entity       = request_params[:entity] if request_params.has_key? :entity

  @headers ||= {}
  @entity ||= ''
end

Instance Attribute Details

#connectionObject

Returns the value of attribute connection.



363
364
365
# File 'bin/httphere', line 363

def connection
  @connection
end

#entityObject

Returns the value of attribute entity.



363
364
365
# File 'bin/httphere', line 363

def entity
  @entity
end

#headersObject

Returns the value of attribute headers.



363
364
365
# File 'bin/httphere', line 363

def headers
  @headers
end

#http_versionObject

Returns the value of attribute http_version.



363
364
365
# File 'bin/httphere', line 363

def http_version
  @http_version
end

#methodObject

Returns the value of attribute method.



363
364
365
# File 'bin/httphere', line 363

def method
  @method
end

#query_paramsObject

Returns the value of attribute query_params.



363
364
365
# File 'bin/httphere', line 363

def query_params
  @query_params
end

#resource_uriObject

Returns the value of attribute resource_uri.



363
364
365
# File 'bin/httphere', line 363

def resource_uri
  @resource_uri
end

#responseObject

Returns the value of attribute response.



363
364
365
# File 'bin/httphere', line 363

def response
  @response
end

Instance Method Details

#basic_authObject



389
390
391
# File 'bin/httphere', line 389

def basic_auth
  BasicAuth.parse(@headers['authorization']) if @headers['authorization']
end

#has_entity?Boolean

Returns:

  • (Boolean)


385
386
387
# File 'bin/httphere', line 385

def has_entity?
  @entity != ''
end

#inspectObject



381
382
383
# File 'bin/httphere', line 381

def inspect
  "HTTP Request:\n\t#{@method} #{@resource_uri} HTTP/#{@http_version}\n\t#{@headers.map {|k,v| "#{k}: #{v}"}.join("\n\t")}\n\n\t#{@entity.to_s.gsub(/\n/,"\n\t")}"
end

#paramsObject



393
394
395
# File 'bin/httphere', line 393

def params
  query_params
end

#ready!Object



364
365
366
# File 'bin/httphere', line 364

def ready!
  @ready = true
end

#ready?Boolean

Returns:

  • (Boolean)


367
368
369
# File 'bin/httphere', line 367

def ready?
  !!@ready
end