Class: FCGI::RecordBuffer
- Inherits:
-
Object
- Object
- FCGI::RecordBuffer
- Defined in:
- lib/cgialt/fcgi/core.rb
Instance Method Summary collapse
- #data ⇒ Object
- #env ⇒ Object
-
#initialize(rec) ⇒ RecordBuffer
constructor
A new instance of RecordBuffer.
- #new_request ⇒ Object
- #push(rec) ⇒ Object
- #ready? ⇒ Boolean
- #stdin ⇒ Object
Constructor Details
#initialize(rec) ⇒ RecordBuffer
Returns a new instance of RecordBuffer.
217 218 219 220 221 222 |
# File 'lib/cgialt/fcgi/core.rb', line 217 def initialize(rec) @begin_request = rec @envs = [] @stdins = [] @datas = [] end |
Instance Method Details
#data ⇒ Object
272 273 274 |
# File 'lib/cgialt/fcgi/core.rb', line 272 def data StringIO.new(@datas.inject('') {|buf, rec| buf << rec.flagment }) end |
#env ⇒ Object
262 263 264 265 266 |
# File 'lib/cgialt/fcgi/core.rb', line 262 def env h = {} @envs.each {|rec| h.update rec.values } h end |
#new_request ⇒ Object
258 259 260 |
# File 'lib/cgialt/fcgi/core.rb', line 258 def new_request Request.new(@begin_request.request_id, env(), stdin(), nil, nil, data()) end |
#push(rec) ⇒ Object
224 225 226 227 228 229 230 231 232 233 234 235 |
# File 'lib/cgialt/fcgi/core.rb', line 224 def push(rec) case rec when ParamsRecord @envs.push rec when StdinDataRecord @stdins.push rec when DataRecord @datas.push rec else raise "got unknown record: #{rec.class}" end end |
#ready? ⇒ Boolean
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
# File 'lib/cgialt/fcgi/core.rb', line 237 def ready? case @begin_request.role when FCGI_RESPONDER completed?(@envs) and completed?(@stdins) when FCGI_AUTHORIZER completed?(@envs) when FCGI_FILTER completed?(@envs) and completed?(@stdins) and completed?(@datas) else raise "unknown role: #{@begin_request.role}" end end |
#stdin ⇒ Object
268 269 270 |
# File 'lib/cgialt/fcgi/core.rb', line 268 def stdin StringIO.new(@stdins.inject('') {|buf, rec| buf << rec.flagment }) end |