add_field

add_field(key, val)
Instance Public methods
Ruby 1.8.3

Adds a value to a named header field, instead of replacing its value. Second argument val must be a String. See also []=, [] and get_fields.

request.add_field 'X-My-Header', 'a'
p request['X-My-Header']              #=> "a"
p request.get_fields('X-My-Header')   #=> ["a"]
request.add_field 'X-My-Header', 'b'
p request['X-My-Header']              #=> "a, b"
p request.get_fields('X-My-Header')   #=> ["a", "b"]
request.add_field 'X-My-Header', 'c'
p request['X-My-Header']              #=> "a, b, c"
p request.get_fields('X-My-Header')   #=> ["a", "b", "c"]
doc_ruby_on_rails
2015-04-21 04:48:52
Comments
Leave a Comment

Please login to continue.