Permalink
Browse files

Be a bit more liberal about how we parse headers for curb and em-http.

  • Loading branch information...
myronmarston committed Feb 19, 2012
1 parent 78db8f1 commit 844cb74dc60126b79015dcfec3f8d19e97591d6f
@@ -90,7 +90,8 @@ def get_body_string(response)
end
def get_header(header_key, response)
- response.response_header[header_key.upcase.gsub('-', '_')].split(', ')
+ values = response.response_header[header_key.upcase.gsub('-', '_')]
+ values.is_a?(Array) ? values : values.split(', ')
end
def make_http_request(method, url, body = nil, headers = {})
@@ -116,11 +117,13 @@ def get_body_string(response)
def get_header(header_key, response)
headers = response.header_str.split("\r\n")[1..-1]
+ value = nil
headers.each do |h|
- if h =~ /^#{Regexp.escape(header_key)}: (.*)$/
- return $1.split(', ')
- end
+ next unless h =~ /^#{Regexp.escape(header_key)}: (.*)$/
+ new_value = $1.split(', ')
+ value = value ? Array(value) + Array(new_value) : new_value
end
+ value
end
def make_http_request(method, url, body = nil, headers = {})
@@ -28,13 +28,7 @@
end
define_method :should_be_pending do
- if header_count == 2
- [
- 'HTTP Client',
- 'EM HTTP Request',
- 'Curb'
- ].include?(adapter_module.http_library_name)
- end
+ header_count == 2 && 'HTTP Client' == adapter_module.http_library_name
end
it 'returns the same header value when recording and replaying' do

0 comments on commit 844cb74

Please sign in to comment.