Browse files

Improved documentation of #shutdown and when to use it. Fixes #20

  • Loading branch information...
drbrain committed Mar 22, 2012
1 parent 49ec8eb commit 99946f010dd4212933e69c869604c12e152153c1
Showing with 18 additions and 2 deletions.
  1. +6 −2 README.rdoc
  2. +12 −0 lib/net/http/persistent.rb
@@ -45,8 +45,12 @@ connection is kept alive between requests:
# perform the POST, the URI is always required
response = http.request post_uri, post
-Please see the documentation for +Net::HTTP::Persistent+ for more information,
-including how to handle SSL connections.
+ # if you are done making http requests, or won't make requests for several
+ # minutes
+ http.shutdown
+Please see the documentation on Net::HTTP::Persistent for more information,
+including SSL connection verification, header handling and tunable options.
@@ -161,6 +161,18 @@
# The method of determining if the resource was created or not is unique to
# the particular service you are using. Of course, you will want to add
# protection from infinite looping.
+# === Connection Termination
+# If you are done using the Net::HTTP::Persistent instance you may shut down
+# all the connections in the current thread with #shutdown. This is not
+# recommended for normal use, it should only be used when it will be several
+# minutes before you make another HTTP request.
+# If you are using multiple threads, call #shutdown in each thread when the
+# thread is done making requests. If you don't call shutdown, that's OK.
+# Ruby will automatically garbage collect and shutdown your HTTP connections
+# when the thread terminates.
class Net::HTTP::Persistent

0 comments on commit 99946f0

Please sign in to comment.