Ignore Errno::EPIPE when sending requests in net/http
An EPIPE when sending the request should be ignored. Even if you cannot write more data, you may still be able to read the server's response. Fixes [Bug #14466]
This commit is contained in:
parent
80d0b6f132
commit
2b6a9f3a1f
Notes:
git
2019-09-27 23:44:04 +09:00
@ -1504,7 +1504,13 @@ module Net #:nodoc:
|
|||||||
begin
|
begin
|
||||||
begin_transport req
|
begin_transport req
|
||||||
res = catch(:response) {
|
res = catch(:response) {
|
||||||
req.exec @socket, @curr_http_version, edit_path(req.path)
|
begin
|
||||||
|
req.exec @socket, @curr_http_version, edit_path(req.path)
|
||||||
|
rescue Errno::EPIPE
|
||||||
|
# Failure when writing full request, but we can probably
|
||||||
|
# still read the received response.
|
||||||
|
end
|
||||||
|
|
||||||
begin
|
begin
|
||||||
res = HTTPResponse.read_new(@socket)
|
res = HTTPResponse.read_new(@socket)
|
||||||
res.decode_content = req.decode_content
|
res.decode_content = req.decode_content
|
||||||
|
@ -890,6 +890,17 @@ class TestNetHTTP_v1_2 < Test::Unit::TestCase
|
|||||||
Net::HTTP.version_1_2
|
Net::HTTP.version_1_2
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_send_large_POST_request
|
||||||
|
start {|http|
|
||||||
|
data = ' '*6000000
|
||||||
|
res = http.send_request('POST', '/', data, 'content-type' => 'application/x-www-form-urlencoded')
|
||||||
|
assert_kind_of Net::HTTPResponse, res
|
||||||
|
assert_kind_of String, res.body
|
||||||
|
assert_equal data.size, res.body.size
|
||||||
|
assert_equal data, res.body
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class TestNetHTTP_v1_2_chunked < Test::Unit::TestCase
|
class TestNetHTTP_v1_2_chunked < Test::Unit::TestCase
|
||||||
|
Loading…
x
Reference in New Issue
Block a user