summaryrefslogtreecommitdiff
path: root/lib/net/http.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/net/http.rb')
-rw-r--r--lib/net/http.rb12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/net/http.rb b/lib/net/http.rb
index bb4934be6f..684e55f8db 100644
--- a/lib/net/http.rb
+++ b/lib/net/http.rb
@@ -416,7 +416,7 @@ module Net # :nodoc:
do_start
return yield(self)
ensure
- finish
+ do_finish
end
end
do_start
@@ -437,12 +437,18 @@ module Net # :nodoc:
private :on_connect
# Finishes HTTP session and closes TCP connection.
+ # Raises IOError if not started.
def finish
+ raise IOError, 'HTTP session not started yet' unless started?
+ do_finish
+ end
+
+ def do_finish
+ @started = false
@socket.close if @socket and not @socket.closed?
@socket = nil
- @started = false
- nil
end
+ private :do_finish
#
# proxy