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:


21
22
23
# File 'lib/http/headers/mixin.rb', line 21

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


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

def_delegator :headers, :[]

#[]=void

This method returns an undefined value.

Sets header.

Parameters:

  • name (#to_s)

    header name

  • value (Array<#to_s>, #to_s)

    header value(s) to be appended


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

def_delegator :headers, :[]=