Class: SpiderGazelle::Spider::Http1::Callbacks
- Inherits:
-
Object
- Object
- SpiderGazelle::Spider::Http1::Callbacks
- Defined in:
- lib/spider-gazelle/spider/http1.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
Returns the value of attribute connection.
-
#parser ⇒ Object
readonly
Returns the value of attribute parser.
Instance Method Summary collapse
-
#initialize ⇒ Callbacks
constructor
A new instance of Callbacks.
- #on_body(parser, data) ⇒ Object
- #on_header_field(parser, header) ⇒ Object
- #on_header_value(parser, value) ⇒ Object
- #on_headers_complete(parser) ⇒ Object
- #on_message_begin(parser) ⇒ Object
- #on_message_complete(parser) ⇒ Object
- #on_url(parser, url) ⇒ Object
Constructor Details
Instance Attribute Details
#connection ⇒ Object
Returns the value of attribute connection.
17 18 19 |
# File 'lib/spider-gazelle/spider/http1.rb', line 17 def connection @connection end |
#parser ⇒ Object (readonly)
Returns the value of attribute parser.
18 19 20 |
# File 'lib/spider-gazelle/spider/http1.rb', line 18 def parser @parser end |
Instance Method Details
#on_body(parser, data) ⇒ Object
57 58 59 |
# File 'lib/spider-gazelle/spider/http1.rb', line 57 def on_body(parser, data) @connection.parsing.body << data end |
#on_header_field(parser, header) ⇒ Object
29 30 31 32 |
# File 'lib/spider-gazelle/spider/http1.rb', line 29 def on_header_field(parser, header) req = @connection.parsing req.header.frozen? ? req.header = header : req.header << header end |
#on_header_value(parser, value) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/spider-gazelle/spider/http1.rb', line 34 def on_header_value(parser, value) req = @connection.parsing if req.header.frozen? req.env[req.header] << value else header = req.header header.upcase! header.gsub!('-', '_') header.prepend('HTTP_') header.freeze if req.env[header] req.env[header] << ', ' req.env[header] << value else req.env[header] = String.new(value) end end end |
#on_headers_complete(parser) ⇒ Object
53 54 55 |
# File 'lib/spider-gazelle/spider/http1.rb', line 53 def on_headers_complete(parser) @connection.headers_complete end |
#on_message_begin(parser) ⇒ Object
21 22 23 |
# File 'lib/spider-gazelle/spider/http1.rb', line 21 def (parser) @connection.start_parsing end |
#on_message_complete(parser) ⇒ Object
61 62 63 |
# File 'lib/spider-gazelle/spider/http1.rb', line 61 def (parser) @connection.finished_parsing end |
#on_url(parser, url) ⇒ Object
25 26 27 |
# File 'lib/spider-gazelle/spider/http1.rb', line 25 def on_url(parser, url) @connection.parsing.url << url end |