Class: CGIIO

Inherits:
Spider::ControllerIO show all
Defined in:
lib/spiderfw/http/adapters/cgi_io.rb

Constant Summary

Constants inherited from Spider::ControllerIO

Spider::ControllerIO::BUFSIZE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Spider::ControllerIO

#flush, #set_body_io

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_sentObject (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_headersObject



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