jnunemaker-httparty 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/History +3 -0
- data/httparty.gemspec +1 -1
- data/lib/httparty/request.rb +1 -0
- data/lib/httparty/version.rb +1 -1
- data/spec/httparty/request_spec.rb +14 -0
- metadata +1 -1
data/History
CHANGED
data/httparty.gemspec
CHANGED
data/lib/httparty/request.rb
CHANGED
@@ -106,6 +106,7 @@ module HTTParty
|
|
106
106
|
# Uses the HTTP Content-Type header to determine the format of the response
|
107
107
|
# It compares the MIME type returned to the types stored in the AllowedFormats hash
|
108
108
|
def format_from_mimetype(mimetype) #:nodoc:
|
109
|
+
return nil if mimetype.nil?
|
109
110
|
AllowedFormats.each { |k, v| return k if mimetype.include?(v) }
|
110
111
|
end
|
111
112
|
|
data/lib/httparty/version.rb
CHANGED
@@ -48,6 +48,20 @@ describe HTTParty::Request do
|
|
48
48
|
response.stub!(:body).and_return("")
|
49
49
|
@request.perform.should be_nil
|
50
50
|
end
|
51
|
+
|
52
|
+
it "should not fail for missing mime type" do
|
53
|
+
http = Net::HTTP.new('localhost', 80)
|
54
|
+
@request.stub!(:http).and_return(http)
|
55
|
+
|
56
|
+
response = Net::HTTPOK.new("1.1", 200, "Content for you")
|
57
|
+
response.stub!(:[]).with('content-type').and_return(nil)
|
58
|
+
response.stub!(:body).and_return('Content for you')
|
59
|
+
|
60
|
+
http.stub!(:request).and_return(response)
|
61
|
+
|
62
|
+
@request.options[:format] = :html
|
63
|
+
@request.perform.should == 'Content for you'
|
64
|
+
end
|
51
65
|
|
52
66
|
describe "that respond with redirects" do
|
53
67
|
def setup_redirect
|