Class: CGIIO
- Inherits:
-
Spider::ControllerIO
- Object
- IO
- Spider::ControllerIO
- CGIIO
- Defined in:
- lib/spiderfw/http/adapters/cgi_io.rb
Constant Summary
Constants inherited from Spider::ControllerIO
Instance Attribute Summary collapse
-
#headers_sent ⇒ Object
readonly
Returns the value of attribute headers_sent.
Instance Method Summary collapse
-
#initialize(out, controller_response) ⇒ CGIIO
constructor
A new instance of CGIIO.
- #send_headers ⇒ Object
- #write(msg) ⇒ Object
Methods inherited from Spider::ControllerIO
Constructor Details
#initialize(out, controller_response) ⇒ CGIIO
Returns a new instance of CGIIO.
4 5 6 7 8 |
# File 'lib/spiderfw/http/adapters/cgi_io.rb', line 4 def initialize(out, controller_response) @out = out @controller_response = controller_response @headers_sent = false end |
Instance Attribute Details
#headers_sent ⇒ Object (readonly)
Returns the value of attribute headers_sent.
2 3 4 |
# File 'lib/spiderfw/http/adapters/cgi_io.rb', line 2 def headers_sent @headers_sent end |
Instance Method Details
#send_headers ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/spiderfw/http/adapters/cgi_io.rb', line 15 def send_headers Spider::Logger.debug("CGI sending headers:") @controller_response.prepare_headers @headers_sent = true @out << "Status: #{@controller_response.status}\n" @controller_response.headers.each do |key, val| @out << "#{key}: #{val}\n" end @out << "\n" end |
#write(msg) ⇒ Object
10 11 12 13 |
# File 'lib/spiderfw/http/adapters/cgi_io.rb', line 10 def write(msg) send_headers unless @headers_sent @out << msg end |