Class: Arpie::HTTPTestProtocol
Overview
This simulates a very basic HTTP XMLRPC client/server. It is not recommended to use this with production code.
Direct Known Subclasses
Constant Summary collapse
- CAN_SEPARATE_MESSAGES =
true
Instance Method Summary collapse
Methods inherited from Protocol
#again!, #assemble, #assemble!, #bogon!, #gulp!, #incomplete!, #to
Instance Method Details
#from(binary) {|body| ... } ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/arpie/xmlrpc.rb', line 72 def from binary # Simply strip all HTTP headers. binary && binary.size > 0 or incomplete! header, body_and_rest = binary.split(/\r\n\r\n/, 2) header && body_and_rest or incomplete! header =~ /^\s*content-length:\s+(\d+)$\s*/xi or stream_error! "No content-length was provided." content_length = $1.to_i content_length <= 0 body_and_rest.size >= content_length or incomplete! body = body_and_rest[0, content_length] yield body header.size + 4 + content_length end |