mirror of
https://github.com/ruby/ruby.git
synced 2025-08-23 13:04:13 +02:00
merge revision(s) 26553:
* lib/net/http.rb (Net::HTTP#request): close @socket only after started. [ruby-core:28028] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@27955 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
5fe5a24586
commit
b6b1a387f1
4 changed files with 47 additions and 7 deletions
|
@ -1,3 +1,8 @@
|
|||
Sat May 22 19:46:27 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* lib/net/http.rb (Net::HTTP#request): close @socket only after
|
||||
started. [ruby-core:28028]
|
||||
|
||||
Sat May 22 19:36:38 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* eval.c (proc_invoke): reverted r25975. [ruby-dev:39931]
|
||||
|
|
|
@ -1044,7 +1044,8 @@ module Net #:nodoc:
|
|||
end
|
||||
|
||||
req.set_body_internal body
|
||||
begin_transport req
|
||||
begin
|
||||
begin_transport req
|
||||
req.exec @socket, @curr_http_version, edit_path(req.path)
|
||||
begin
|
||||
res = HTTPResponse.read_new(@socket)
|
||||
|
@ -1052,13 +1053,14 @@ module Net #:nodoc:
|
|||
res.reading_body(@socket, req.response_body_permitted?) {
|
||||
yield res if block_given?
|
||||
}
|
||||
end_transport req, res
|
||||
end_transport req, res
|
||||
rescue => exception
|
||||
D "Conn close because of error #{exception}"
|
||||
@socket.close unless @socket.closed?
|
||||
raise exception
|
||||
end
|
||||
|
||||
res
|
||||
rescue => exception
|
||||
D "Conn close because of error #{exception}"
|
||||
@socket.close unless @socket.closed?
|
||||
raise exception
|
||||
end
|
||||
|
||||
private
|
||||
|
|
33
test/net/http/test_connection.rb
Normal file
33
test/net/http/test_connection.rb
Normal file
|
@ -0,0 +1,33 @@
|
|||
require 'net/http'
|
||||
require 'test/unit'
|
||||
|
||||
module TestHTTP
|
||||
class HTTPConnectionTest < Test::Unit::TestCase
|
||||
def test_connection_refused_in_request
|
||||
bug2708 = '[ruby-core:28028]'
|
||||
port = nil
|
||||
localhost = "127.0.0.1"
|
||||
t = Thread.new {
|
||||
TCPServer.open(localhost, 0) do |serv|
|
||||
_, port, _, _ = serv.addr
|
||||
if clt = serv.accept
|
||||
clt.close
|
||||
end
|
||||
end
|
||||
}
|
||||
begin
|
||||
sleep 0.1 until port
|
||||
assert_raise(Errno::ECONNRESET, bug2708) {
|
||||
n = Net::HTTP.new(localhost, port)
|
||||
n.request_get('/')
|
||||
}
|
||||
ensure
|
||||
t.join if t
|
||||
end
|
||||
assert_raise(Errno::ECONNREFUSED, bug2708) {
|
||||
n = Net::HTTP.new(localhost, port)
|
||||
n.request_get('/')
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
|
@ -2,7 +2,7 @@
|
|||
#define RUBY_RELEASE_DATE "2010-05-22"
|
||||
#define RUBY_VERSION_CODE 187
|
||||
#define RUBY_RELEASE_CODE 20100522
|
||||
#define RUBY_PATCHLEVEL 260
|
||||
#define RUBY_PATCHLEVEL 261
|
||||
|
||||
#define RUBY_VERSION_MAJOR 1
|
||||
#define RUBY_VERSION_MINOR 8
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue