class Net::PTTH::Parser
Attributes
chunk[R]
headers[R]
Public Class Methods
new()
click to toggle source
Public: Contructor
# File lib/net/ptth/parser.rb, line 9 def initialize @parser = Http::Parser.new(self) reset end
Public Instance Methods
add(data)
click to toggle source
Public: Adds data to be parsed.
data: string to be parsed
# File lib/net/ptth/parser.rb, line 18 def add(data) @parser << data end
Also aliased as: <<
body()
click to toggle source
Public: Access the body of the string being parsed
# File lib/net/ptth/parser.rb, line 67 def body @chunk end
body=(chunk)
click to toggle source
# File lib/net/ptth/parser.rb, line 71 def body=(chunk) @chunk << chunk end
finished?()
click to toggle source
Public: Internal flag access to know when parsing ended
# File lib/net/ptth/parser.rb, line 55 def finished?; @finished; end
http_method()
click to toggle source
Public: Gets the http method parsed
# File lib/net/ptth/parser.rb, line 31 def http_method @parser.http_method end
http_version()
click to toggle source
Public: Gets the http version parsed
# File lib/net/ptth/parser.rb, line 37 def http_version @parser.http_version end
on_headers_complete(headers)
click to toggle source
Protected: Sets the headers when the parser completes.
# File lib/net/ptth/parser.rb, line 77 def on_headers_complete(headers) @headers = headers end
on_message_begin()
click to toggle source
# File lib/net/ptth/parser.rb, line 81 def on_message_begin reset end
on_message_complete()
click to toggle source
Protected: Flags the parsing as ended
# File lib/net/ptth/parser.rb, line 87 def on_message_complete @finished = true end
reset()
click to toggle source
Public: Resets the parser internal flags
# File lib/net/ptth/parser.rb, line 59 def reset @finished = false @headers = nil @chunk = "" end
status_code()
click to toggle source
Public: Gets the status code parsed
# File lib/net/ptth/parser.rb, line 43 def status_code @parser.status_code end
upgrade?()
click to toggle source
Public: Check for an upgrade header in the parsed string
# File lib/net/ptth/parser.rb, line 25 def upgrade? @parser.upgrade? end
url()
click to toggle source
Public: Gets the url parsed
# File lib/net/ptth/parser.rb, line 49 def url @parser.request_url end