1
0
Fork 0
mirror of https://github.com/rest-client/rest-client.git synced 2022-11-09 13:49:40 -05:00

a test and fix for 204 No Content responses, to ensure that the response object (and all important headers) are still returned

This commit is contained in:
El Draper 2009-10-07 19:22:58 +01:00 committed by Julien Kirch
parent 1f8b272cfe
commit e4d01c7688
2 changed files with 15 additions and 1 deletions

View file

@ -144,7 +144,7 @@ module RestClient
elsif @raw_response elsif @raw_response
RawResponse.new(@tf, res) RawResponse.new(@tf, res)
else else
nil Response.new(nil, res)
end end
end end
rescue EOFError rescue EOFError

View file

@ -481,4 +481,18 @@ describe RestClient::Request do
@request.stub!(:response_log) @request.stub!(:response_log)
@request.transmit(@uri, 'req', 'payload') @request.transmit(@uri, 'req', 'payload')
end end
it "should still return a response object for 204 No Content responses" do
@request = RestClient::Request.new(
:method => :put,
:url => 'https://some/resource',
:payload => 'payload'
)
net_http_res = Net::HTTPNoContent.new("", "204", "No Content")
net_http_res.stub(:read_body).and_return(nil)
@http.should_receive(:request).and_return(@request.fetch_body(net_http_res))
response = @request.transmit(@uri, 'req', 'payload')
response.should_not be_nil
response.code.should equal(204)
end
end end