Class: Restfulie::Client::Feature::SetupHeader

Inherits:
Object
  • Object
show all
Defined in:
lib/restfulie/client/feature/setup_header.rb

Instance Method Summary collapse

Instance Method Details

#execute(flow, request, env) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/restfulie/client/feature/setup_header.rb', line 5

def execute(flow, request, env)
  headers = request.default_headers.dup.merge(request.headers)
  host = request.host
  if host.user || host.password
    headers["Authorization"] = "Basic " + ["#{host.user}:#{host.password}"].pack("m").delete("\r\n")
  end
  headers.delete :recipe
  headers['cookie'] = request.cookies if request.cookies
  
  # gs: this should not be overriden, do it in some other way
  request.headers = headers
  
  flow.continue(request, env)
end