Class: RestMan::Request::MakeHeaders

Inherits:
ActiveMethod::Base
  • Object
show all
Defined in:
lib/restman/request/make_headers.rb

Instance Method Summary collapse

Instance Method Details

#callObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/restman/request/make_headers.rb', line 7

def call
  headers = StringifyHeaders.call(default_headers).merge(StringifyHeaders.call(user_headers))

  # override headers from the payload (e.g. Content-Type, Content-Length)
  if payload
    headers = payload.headers.merge(headers)
  end

  # merge in cookies
  cookies = request.make_cookie_header
  if cookies && !cookies.empty?
    if headers['Cookie']
      warn('warning: overriding "Cookie" header with :cookies option')
    end
    headers['Cookie'] = cookies
  end

  headers
end