Class: Async::HTTP::Request

Inherits:
Object
  • Object
show all
Includes:
Body::Reader
Defined in:
lib/async/http/request.rb

Direct Known Subclasses

Protocol::Request

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Body::Reader

#body?, #close, #each, #finish, #read, #stop

Constructor Details

#initialize(authority = nil, method = nil, path = nil, version = nil, headers = [], body = nil) ⇒ Request

Returns a new instance of Request.



30
31
32
33
34
35
36
37
# File 'lib/async/http/request.rb', line 30

def initialize(authority = nil, method = nil, path = nil, version = nil, headers = [], body = nil)
	@authority = authority
	@method = method
	@path = path
	@version = version
	@headers = headers
	@body = body
end

Instance Attribute Details

#authorityObject

Returns the value of attribute authority.



39
40
41
# File 'lib/async/http/request.rb', line 39

def authority
  @authority
end

#bodyObject

Returns the value of attribute body.



44
45
46
# File 'lib/async/http/request.rb', line 44

def body
  @body
end

#headersObject

Returns the value of attribute headers.



43
44
45
# File 'lib/async/http/request.rb', line 43

def headers
  @headers
end

#methodObject

Returns the value of attribute method.



40
41
42
# File 'lib/async/http/request.rb', line 40

def method
  @method
end

#pathObject

Returns the value of attribute path.



41
42
43
# File 'lib/async/http/request.rb', line 41

def path
  @path
end

#versionObject

Returns the value of attribute version.



42
43
44
# File 'lib/async/http/request.rb', line 42

def version
  @version
end

Class Method Details

.[](method, path, headers, body) ⇒ Object



54
55
56
57
58
# File 'lib/async/http/request.rb', line 54

def self.[](method, path, headers, body)
	body = Body::Buffered.wrap(body)
	
	self.new(nil, method, path, nil, headers, body)
end

Instance Method Details

#connect?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/async/http/request.rb', line 50

def connect?
	self.method == CONNECT
end

#head?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/async/http/request.rb', line 46

def head?
	self.method == HEAD
end

#idempotent?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/async/http/request.rb', line 60

def idempotent?
	method != POST && (body.nil? || body.empty?)
end

#to_sObject



64
65
66
# File 'lib/async/http/request.rb', line 64

def to_s
	"#{@method} #{@path} #{@version}"
end