Class

Rack::Response

Inheritance
< Object
Included Modules
Helpers

Rack::Response provides a convenient interface to create a Rack response.

It allows setting of headers and cookies, and provides useful defaults (a OK response containing HTML).

You can use Response#write to iteratively generate your response, but note that this is buffered by Rack::Response until you call finish. finish however can take a block inside which calls to write are syncronous with the Rack response.

Your application‘s call should end returning Response#finish.

Classes & Modules

Attributes

Name Visibility R/W Description
body public RW
header public R
length public RW
status public RW

Aliases

Method Alias Description
header → headers

Methods

Class

Visibility Signature
public new (body=[], status=200, header={}) {|self if block_given?| ...}

Instance

Visibility Signature
public [] (key)
public []= (key, value)
public close ()
public delete_cookie (key, value={})
public each (&callback)
public empty? ()
public finish (&block)
public set_cookie (key, value)
public to_a (&block)
public write (str)

Class Method Detail

new(body=[], status=200, header={}) {|self if block_given?| ...}

Instance Method Detail

[](key)

[]=(key, value)

close()

delete_cookie(key, value={})

each(&callback)

empty?()

finish(&block)

set_cookie(key, value)

to_a(&block)

Alias for finish

write(str)

Append to body and update Content-Length.

NOTE: Do not mix write and direct body access!