Module: HTTP::Headers::Mixin

Extended by:
Forwardable
Included in:
Request, Response
Defined in:
lib/http/headers/mixin.rb

Overview

Provides shared behavior for Request and Response. Expects @headers to be an instance of HTTP::Headers.

Examples:

Usage


class MyHttpRequest
  include HTTP::Headers::Mixin

  def initialize
    @headers = HTTP::Headers.new
  end
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#headersHTTP::Headers (readonly)

Returns:



23
24
25
# File 'lib/http/headers/mixin.rb', line 23

def headers
  @headers
end

Instance Method Details

#[]nil, ...

Smart version of HTTP::Headers#get.

Returns:

  • (nil)

    if header was not set

  • (String)

    if header has exactly one value

  • (Array<String>)

    if header has more than one value



27
# File 'lib/http/headers/mixin.rb', line 27

def_delegator :headers, :[]

#[]=void

This method returns an undefined value.

Sets header.



31
# File 'lib/http/headers/mixin.rb', line 31

def_delegator :headers, :[]=