<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>test/timeout_test.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,6 +1,10 @@
 
 = rufus-verbs CHANGELOG.txt
 
+== rufus-verbs - 0.10   not yet released
+
+- todo #18981 : added timeout tuning (:timeout / :to)
+
 
 == rufus-verbs - 0.9    released 2008/04/10
 </diff>
      <filename>CHANGELOG.txt</filename>
    </modified>
    <modified>
      <diff>@@ -288,6 +288,12 @@ the resource (or the middle) of a full resource path (see :base)
 * &lt;b&gt;:ssl_verify_peer&lt;/b&gt; (boolean, RE)
 by default, rufus-verbs doesn't verify ssl certificates. With this option set to true, it will.
 
+* &lt;b&gt;:timeout&lt;/b&gt; (integer, RE)
+sets the timeout (both open_ and read_timeout) for the request (and the endpoint), expects a value expressed in seconds.
+
+* &lt;b&gt;:to&lt;/b&gt; (integer, RE)
+shortcut for :timeout
+
 * &lt;b&gt;:u&lt;/b&gt; (uri, string, RE)
 the short version of :uri
 </diff>
      <filename>README.txt</filename>
    </modified>
    <modified>
      <diff>@@ -8,10 +8,10 @@
 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 # copies of the Software, and to permit persons to whom the Software is
 # furnished to do so, subject to the following conditions:
-# 
+#
 # The above copyright notice and this permission notice shall be included in
 # all copies or substantial portions of the Software.
-# 
+#
 # THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE</diff>
      <filename>lib/rufus/verbs.rb</filename>
    </modified>
    <modified>
      <diff>@@ -8,10 +8,10 @@
 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 # copies of the Software, and to permit persons to whom the Software is
 # furnished to do so, subject to the following conditions:
-# 
+#
 # The above copyright notice and this permission notice shall be included in
 # all copies or substantial portions of the Software.
-# 
+#
 # THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -49,12 +49,12 @@ module Verbs
     USER_AGENT = &quot;Ruby rufus-verbs #{VERSION}&quot;
 
     #
-    # An EndPoint can be used to share common options among a set of 
+    # An EndPoint can be used to share common options among a set of
     # requests.
     #
     #     ep = EndPoint.new(
-    #         :host =&gt; &quot;restful.server&quot;, 
-    #         :port =&gt; 7080, 
+    #         :host =&gt; &quot;restful.server&quot;,
+    #         :port =&gt; 7080,
     #         :resource =&gt; &quot;inventory/tools&quot;)
     #
     #     res = ep.get :id =&gt; 1
@@ -63,7 +63,7 @@ module Verbs
     #     res = ep.get :id =&gt; 0
     #         # where did the hammer go ?
     #
-    # When a request gets prepared, the option values will be looked up 
+    # When a request gets prepared, the option values will be looked up
     # in (1) its local (request) options, then (2) in the EndPoint options.
     #
     class EndPoint
@@ -83,7 +83,7 @@ module Verbs
 
             compute_target @opts
 
-            @opts[:http_basic_authentication] = 
+            @opts[:http_basic_authentication] =
                 opts[:http_basic_authentication] || opts[:hba]
 
             @opts[:user_agent] ||= USER_AGENT
@@ -126,7 +126,7 @@ module Verbs
         #
         # This is the method called by the module methods verbs.
         #
-        # For example, 
+        # For example,
         #
         #     RufusVerbs.get(args)
         #
@@ -264,10 +264,10 @@ module Verbs
                 elsif u
 
                     u = URI.parse u.to_s unless u.is_a?(URI)
-                    [ u.scheme, 
-                      u.host, 
-                      u.port, 
-                      u.path, 
+                    [ u.scheme,
+                      u.host,
+                      u.port,
+                      u.path,
                       query_to_h(u.query) ]
                 else
 
@@ -279,18 +279,18 @@ module Verbs
                 opts[:port] = r[2] || @opts[:port]
                 opts[:path] = r[3] || @opts[:path]
 
-                opts[:query] = 
-                    r[4] || 
+                opts[:query] =
+                    r[4] ||
                     opts[:params] || opts[:query] ||
-                    @opts[:query] || @opts[:params] || 
+                    @opts[:query] || @opts[:params] ||
                     {}
 
                 opts.delete :path if opts[:path] == &quot;&quot;
 
-                opts[:c_uri] = [ 
-                    opts[:scheme], 
-                    opts[:host], 
-                    opts[:port], 
+                opts[:c_uri] = [
+                    opts[:scheme],
+                    opts[:host],
+                    opts[:port],
                     opts[:path],
                     opts[:query] ].inspect
                         #
@@ -303,7 +303,7 @@ module Verbs
             # Creates the Net::HTTP request instance.
             #
             # If :fake_put is set, will use Net::HTTP::Post
-            # and make sure the query string contains '_method=put' (or 
+            # and make sure the query string contains '_method=put' (or
             # '_method=delete').
             #
             # This call will also advertise this rufus-verbs as
@@ -311,7 +311,7 @@ module Verbs
             #
             def create_request (method, opts)
 
-                if (o(opts, :fake_put) and 
+                if (o(opts, :fake_put) and
                     (method == :put or method == :delete))
 
                     opts[:query][:_method] = method.to_s
@@ -362,7 +362,7 @@ module Verbs
             end
 
             #
-            # In that base class, it's empty. 
+            # In that base class, it's empty.
             # It's implemented in ConditionalEndPoint.
             #
             # Only called for a GET.
@@ -381,10 +381,12 @@ module Verbs
                 compute_proxy opts
 
                 http = Net::HTTP.new(
-                    opts[:host], opts[:port], 
+                    opts[:host], opts[:port],
                     opts[:proxy_host], opts[:proxy_port],
                     opts[:proxy_user], opts[:proxy_pass])
 
+                set_timeout http, opts
+
                 return http unless opts[:scheme] == 'https'
 
                 require 'net/https'
@@ -406,6 +408,21 @@ module Verbs
             end
 
             #
+            # Sets both the open_timeout and the read_timeout for the http
+            # instance
+            #
+            def set_timeout (http, opts)
+
+                to = o(opts, :timeout) || o(opts, :to)
+                to = to.to_i
+
+                return if to == 0
+
+                http.open_timeout = to
+                http.read_timeout = to
+            end
+
+            #
             # Makes sure the request opts hold the proxy information.
             #
             # If the option :proxy is set to false, no proxy will be used.
@@ -466,7 +483,7 @@ module Verbs
 
                 return nil unless q
 
-                q.split(&quot;&amp;&quot;).inject({}) do |r, e| 
+                q.split(&quot;&amp;&quot;).inject({}) do |r, e|
                     s = e.split(&quot;=&quot;)
                     r[s[0]] = s[1]
                     r
@@ -474,11 +491,11 @@ module Verbs
             end
 
             #
-            #     { &quot;a&quot; =&gt; &quot;A&quot;, &quot;b&quot; =&gt; &quot;B&quot; } -&gt; &quot;a=A&amp;b=B&quot; 
+            #     { &quot;a&quot; =&gt; &quot;A&quot;, &quot;b&quot; =&gt; &quot;B&quot; } -&gt; &quot;a=A&amp;b=B&quot;
             #
             def h_to_query (h, opts)
 
-                h.entries.collect { |k, v| 
+                h.entries.collect { |k, v|
                     unless o(opts, :no_escape)
                         k = URI.escape k.to_s
                         v = URI.escape v.to_s
@@ -502,7 +519,7 @@ module Verbs
                     req.set_form_data fd, sep
                 elsif block
                     req.body = block.call req
-                else 
+                else
                     req.body = &quot;&quot;
                 end
             end
@@ -544,7 +561,7 @@ module Verbs
                         opts[:path], opts[:query] = location.split &quot;?&quot;
                     end
 
-                    if (authentication_is_on?(opts) and 
+                    if (authentication_is_on?(opts) and
                         [ opts[:scheme], opts[:host] ] != prev_host)
 
                         raise(</diff>
      <filename>lib/rufus/verbs/endpoint.rb</filename>
    </modified>
    <modified>
      <diff>@@ -276,6 +276,17 @@ class CookieServlet &lt; WEBrick::HTTPServlet::AbstractServlet
 end
 
 #
+# a servlet that doesn't reply (for timeout testing)
+#
+class LostServlet &lt; WEBrick::HTTPServlet::AbstractServlet
+
+    def do_GET (req, res)
+
+        sleep 200
+    end
+end
+
+#
 # Serving items, a dummy resource...
 # Also serving things, which just redirect to items...
 #
@@ -300,6 +311,7 @@ class ItemServer
         @server.mount &quot;/items&quot;, ItemServlet
         @server.mount &quot;/things&quot;, ThingServlet
         @server.mount &quot;/cookie&quot;, CookieServlet
+        @server.mount &quot;/lost&quot;, LostServlet
 
         [ 'INT', 'TERM' ].each do |signal|
             trap(signal) { shutdown }</diff>
      <filename>test/items.rb</filename>
    </modified>
    <modified>
      <diff>@@ -24,3 +24,5 @@ require 'escape_test'
 require 'uri_test'
 require 'fopen_test'
 
+require 'timeout_test'
+</diff>
      <filename>test/test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>9a7742c3eec0613de6e1ffce746a7c3b91236727</id>
    </parent>
  </parents>
  <author>
    <name>John Mettraux</name>
    <email>jmettraux@gmail.com</email>
  </author>
  <url>http://github.com/jmettraux/rufus-verbs/commit/a8e7dc8b79e15249ff75890ba373c6214dbad5ea</url>
  <id>a8e7dc8b79e15249ff75890ba373c6214dbad5ea</id>
  <committed-date>2008-05-26T01:30:20-07:00</committed-date>
  <authored-date>2008-05-26T01:30:20-07:00</authored-date>
  <message>todo #18981 : added timeout tuning (:timeout / :to)</message>
  <tree>a3bb43d8827c6313273c9c57650225a01995574c</tree>
  <committer>
    <name>John Mettraux</name>
    <email>jmettraux@gmail.com</email>
  </committer>
</commit>
