Class: Cocaine::Http::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/cocaine/server/http.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rq) ⇒ Request



13
14
15
# File 'lib/cocaine/server/http.rb', line 13

def initialize(rq)
  @ch = rq.read
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



11
12
13
# File 'lib/cocaine/server/http.rb', line 11

def body
  @body
end

#headersObject (readonly)

Returns the value of attribute headers.



11
12
13
# File 'lib/cocaine/server/http.rb', line 11

def headers
  @headers
end

#methodObject (readonly)

Returns the value of attribute method.



11
12
13
# File 'lib/cocaine/server/http.rb', line 11

def method
  @method
end

#queryObject (readonly)

Returns the value of attribute query.



11
12
13
# File 'lib/cocaine/server/http.rb', line 11

def query
  @query
end

#versionObject (readonly)

Returns the value of attribute version.



11
12
13
# File 'lib/cocaine/server/http.rb', line 11

def version
  @version
end

Instance Method Details

#readObject



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/cocaine/server/http.rb', line 17

def read
  ch = Cocaine::Channel.new
  @ch.callback { |msg|
    @method, url, @version, headers, @body = MessagePack::unpack msg
    @headers = Hash[headers]
    tmp_query = URI.parse(url).query
    @query = tmp_query == nil ? {} : CGI.parse(tmp_query)
    ch.trigger self
  }.errback { |err|
    ch.error err
  }
  ch
end