summaryrefslogtreecommitdiff
path: root/lib/net
diff options
context:
space:
mode:
Diffstat (limited to 'lib/net')
-rw-r--r--lib/net/http.rb14
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/net/http.rb b/lib/net/http.rb
index 59e9c0c7f0..0f72b7ae9f 100644
--- a/lib/net/http.rb
+++ b/lib/net/http.rb
@@ -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