Sha256: a42e362fefda86b25f65d2073b37424af2f4bb2bca38092653f40cab421dc09b
Contents?: true
Size: 936 Bytes
Versions: 7
Compression:
Stored size: 936 Bytes
Contents
module Excon module Middleware class CaptureCookies < Excon::Middleware::Base def extract_cookies_from_set_cookie(set_cookie) set_cookie.split(',').map { |full| full.split(';').first.strip }.join('; ') end def get_header(datum, header) _, header_value = datum[:response][:headers].detect do |key, value| key.casecmp(header) == 0 end header_value end def response_call(datum) cookie = get_header(datum, 'Set-Cookie') if cookie cookie = extract_cookies_from_set_cookie(cookie) unless datum[:headers].key?("Cookie") datum[:headers]["Cookie"] = cookie else original_cookies = datum[:headers]["Cookie"] datum[:headers]["Cookie"] = original_cookies.empty? ? cookie : [original_cookies,cookie].join('; ') end end super(datum) end end end end
Version data entries
7 entries across 7 versions & 1 rubygems