Class: Ebb::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/ebb.rb,
ext/ebb_ffi.c

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#connectionObject

Returns the value of attribute connection.



259
260
261
# File 'lib/ebb.rb', line 259

def connection
  @connection
end

Instance Method Details

#envObject



261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
# File 'lib/ebb.rb', line 261

def env
  @env ||= begin
    @env_ffi.update(
      'SERVER_NAME' => '0.0.0.0',
      'SCRIPT_NAME' => '',
      'SERVER_SOFTWARE' => Ebb::VERSION_STRING,
      'SERVER_PROTOCOL' => 'HTTP/1.1',
      'rack.version' => [0, 1],
      'rack.errors' => STDERR,
      'rack.url_scheme' => 'http',
      'rack.multiprocess' => false,
      'rack.run_once' => false,

      'rack.input' => self,
      'async.callback' => response,
      'CONTENT_LENGTH' => @env_ffi.delete('HTTP_CONTENT_LENGTH'),
      'CONTENT_TYPE' => @env_ffi.delete('HTTP_CONTENT_TYPE')
    )
  end
end

#keep_alive?Boolean

Returns:

  • (Boolean)


282
283
284
# File 'lib/ebb.rb', line 282

def keep_alive?
  FFI::request_should_keep_alive?(self)
end

#read(want = 1024) ⇒ Object



293
294
295
# File 'lib/ebb.rb', line 293

def read(want = 1024)
  FFI::request_read(self, want)
end

#responseObject



286
287
288
289
290
291
# File 'lib/ebb.rb', line 286

def response
  @response ||= begin
    last = !keep_alive? # this is the last response if the request isnt keep-alive
    Response.new(@connection, last)
  end
end