Class: UDPRest::UHTTPRequest
- Inherits:
-
Object
- Object
- UDPRest::UHTTPRequest
- Defined in:
- lib/udp_rest/uhttp.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
Returns the value of attribute path.
-
#protocol ⇒ Object
Returns the value of attribute protocol.
-
#req_method ⇒ Object
Returns the value of attribute req_method.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ UHTTPRequest
constructor
A new instance of UHTTPRequest.
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ UHTTPRequest
Returns a new instance of UHTTPRequest.
11 12 13 14 15 |
# File 'lib/udp_rest/uhttp.rb', line 11 def initialize self.req_method = 'GET' self.protocol = 'UHTTP/1.0' self.path ='/' end |
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
8 9 10 |
# File 'lib/udp_rest/uhttp.rb', line 8 def path @path end |
#protocol ⇒ Object
Returns the value of attribute protocol.
9 10 11 |
# File 'lib/udp_rest/uhttp.rb', line 9 def protocol @protocol end |
#req_method ⇒ Object
Returns the value of attribute req_method.
7 8 9 |
# File 'lib/udp_rest/uhttp.rb', line 7 def req_method @req_method end |
Class Method Details
.from_packet(p) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/udp_rest/uhttp.rb', line 17 def self.from_packet(p) text = p text = p.text if text.is_a? UDPPacket data = text.split(' ') raise 'invalid request' if data.length != 3 req = self.new req.req_method = data[0] req.path = data[1] req.protocol = data[2] return req end |
Instance Method Details
#to_s ⇒ Object
30 31 32 33 |
# File 'lib/udp_rest/uhttp.rb', line 30 def to_s self.path = '/' if path.nil? || path.empty? "#{req_method} #{path} #{protocol}\n" end |