patron 0.9.1 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f6d71dc0eaded4e48a770c409f82a571a4f77151
4
- data.tar.gz: cdf33d99ce93e86f79d7889860be83f2cb87ba94
3
+ metadata.gz: 4e380f44f007f28da3773814cfb58b14feee67d9
4
+ data.tar.gz: 799cc7f47f3897ea44cf8f843e1608219444f354
5
5
  SHA512:
6
- metadata.gz: c7d7a4a3832c5b9774cc8171b51e69c15fba9d9d05a050b0ecda76c437ee3db9bb87aad218dfd3f34b54bb34e99612f410e56a0ab21714f5010b3fdb381bbd01
7
- data.tar.gz: 72dddcb493902c90deb114655c61a247a7927f2be526c212a8294be5c3a0bb144fd92fb666450a84cd83c249a91f2b105d9508caf87210b432acec5b85ae496f
6
+ metadata.gz: 8236a3a412232c0bb956476f7031d13ebdfb570a9e583dcf9c064ce2ac7dd83c61a17022c92f0d223baf80e37749d25d1ece6212b39d2ade81c9caf2e552e08a
7
+ data.tar.gz: 9b7540a564c74bc40116ce2accab42d0bdf48abd428828bdf3d12a3e77a250b781e99f92d63b569b7993be7de4bc4ac9b423d9181b1db4280689cebbe1315377
data/.gitignore CHANGED
@@ -6,4 +6,5 @@ rdoc
6
6
  doc
7
7
  pkg
8
8
  tmp
9
- .yardoc
9
+ .yardoc
10
+ Gemfile.lock
@@ -2,8 +2,12 @@ rvm:
2
2
  - 1.9.3
3
3
  - 2.1.5
4
4
  - 2.2.2
5
- - 2.3.0
5
+ - 2.3.4
6
6
  - 2.4.1
7
7
  sudo: false
8
8
  dist: trusty
9
9
  cache: bundler
10
+ install:
11
+ - gem update --system 2.6.12 # https://github.com/rubygems/rubygems/issues/2024
12
+ - gem install bundler
13
+ - "bundle install --verbose --jobs=3 --retry=3 --path=${BUNDLE_PATH:-vendor/bundle}"
@@ -1,3 +1,10 @@
1
+ ### 0.10.0
2
+
3
+ * Added `Session#low_speed_time` and `Session#low_speed_limit`. When used, they will force libCURL to raise
4
+ a timeout if a certain speed limit is not met performing the request. These can be used for better timeout
5
+ handling. These are available in all libCURL versions. See https://curl.haxx.se/libcurl/c/CURLOPT_LOW_SPEED_TIME.html
6
+ and https://curl.haxx.se/libcurl/c/CURLOPT_LOW_SPEED_LIMIT.html
7
+
1
8
  ### 0.9.1
2
9
 
3
10
  * Added ssl_version options `TLSv1_1`, `TLSv1_2`, `TLSv1_3` for explicitly forcing the SSL version
data/README.md CHANGED
@@ -105,5 +105,4 @@ similar. For Windows we do not have an established build instruction at the mome
105
105
 
106
106
  sudo gem install patron
107
107
 
108
-
109
108
  Copyright (c) 2008 The Hive
data/Rakefile CHANGED
@@ -1,26 +1,3 @@
1
- ## -------------------------------------------------------------------
2
- ##
3
- ## Copyright (c) 2008 The Hive http://www.thehive.com/
4
- ##
5
- ## Permission is hereby granted, free of charge, to any person obtaining a copy
6
- ## of this software and associated documentation files (the "Software"), to deal
7
- ## in the Software without restriction, including without limitation the rights
8
- ## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- ## copies of the Software, and to permit persons to whom the Software is
10
- ## furnished to do so, subject to the following conditions:
11
- ##
12
- ## The above copyright notice and this permission notice shall be included in
13
- ## all copies or substantial portions of the Software.
14
- ##
15
- ## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- ## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- ## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- ## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- ## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- ## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- ## THE SOFTWARE.
22
- ##
23
- ## -------------------------------------------------------------------
24
1
  require 'rake/clean'
25
2
  require 'rake/extensiontask'
26
3
  require 'rspec/core/rake_task'
@@ -1,28 +1,3 @@
1
- ## -------------------------------------------------------------------
2
- ##
3
- ## Copyright (c) 2008 The Hive http://www.thehive.com/
4
- ##
5
- ## Permission is hereby granted, free of charge, to any person obtaining a copy
6
- ## of this software and associated documentation files (the "Software"), to deal
7
- ## in the Software without restriction, including without limitation the rights
8
- ## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- ## copies of the Software, and to permit persons to whom the Software is
10
- ## furnished to do so, subject to the following conditions:
11
- ##
12
- ## The above copyright notice and this permission notice shall be included in
13
- ## all copies or substantial portions of the Software.
14
- ##
15
- ## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- ## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- ## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- ## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- ## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- ## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- ## THE SOFTWARE.
22
- ##
23
- ## -------------------------------------------------------------------
24
-
25
-
26
1
  require 'mkmf'
27
2
  require 'rbconfig'
28
3
 
@@ -1,27 +1,3 @@
1
- /* -------------------------------------------------------------------------- *\
2
- *
3
- * Patron HTTP Client: Interface to libcurl
4
- * Copyright (c) 2008 The Hive http://www.thehive.com/
5
- *
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy
7
- * of this software and associated documentation files (the "Software"), to deal
8
- * in the Software without restriction, including without limitation the rights
9
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- * copies of the Software, and to permit persons to whom the Software is
11
- * furnished to do so, subject to the following conditions:
12
- *
13
- * The above copyright notice and this permission notice shall be included in
14
- * all copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
- * THE SOFTWARE.
23
- *
24
- \* -------------------------------------------------------------------------- */
25
1
  #include <ruby.h>
26
2
  #if defined(USE_TBR) && defined(HAVE_THREAD_H)
27
3
  #include <ruby/thread.h>
@@ -571,6 +547,16 @@ static void set_options_from_request(VALUE self, VALUE request) {
571
547
  curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, FIX2INT(timeout));
572
548
  }
573
549
 
550
+ VALUE low_speed_time = rb_funcall(request, rb_intern("low_speed_time"), 0);
551
+ if(RTEST(low_speed_time)) {
552
+ curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, FIX2LONG(low_speed_time));
553
+ }
554
+
555
+ VALUE low_speed_limit_bytes_per_second = rb_funcall(request, rb_intern("low_speed_limit"), 0);
556
+ if(RTEST(low_speed_limit_bytes_per_second)) {
557
+ curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, FIX2LONG(low_speed_limit_bytes_per_second));
558
+ }
559
+
574
560
  redirects = rb_funcall(request, rb_intern("max_redirects"), 0);
575
561
  if (RTEST(redirects)) {
576
562
  int r = FIX2INT(redirects);
@@ -1,34 +1,7 @@
1
- ## -------------------------------------------------------------------
2
- ##
3
- ## Patron HTTP Client: Bootstrap script
4
- ## Copyright (c) 2008 The Hive http://www.thehive.com/
5
- ##
6
- ## Permission is hereby granted, free of charge, to any person obtaining a copy
7
- ## of this software and associated documentation files (the "Software"), to deal
8
- ## in the Software without restriction, including without limitation the rights
9
- ## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- ## copies of the Software, and to permit persons to whom the Software is
11
- ## furnished to do so, subject to the following conditions:
12
- ##
13
- ## The above copyright notice and this permission notice shall be included in
14
- ## all copies or substantial portions of the Software.
15
- ##
16
- ## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- ## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- ## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- ## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- ## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- ## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
- ## THE SOFTWARE.
23
- ##
24
- ## -------------------------------------------------------------------
25
-
26
-
27
1
  require 'pathname'
28
2
 
29
3
  cwd = Pathname(__FILE__).dirname
30
4
  $:.unshift(cwd.to_s) unless $:.include?(cwd.to_s) || $:.include?(cwd.expand_path.to_s)
31
-
32
5
  require 'patron/session'
33
6
  require 'patron/version'
34
7
 
@@ -1,29 +1,3 @@
1
- ## -------------------------------------------------------------------
2
- ##
3
- ## Patron HTTP Client: Error definitions
4
- ## Copyright (c) 2008 The Hive http://www.thehive.com/
5
- ##
6
- ## Permission is hereby granted, free of charge, to any person obtaining a copy
7
- ## of this software and associated documentation files (the "Software"), to deal
8
- ## in the Software without restriction, including without limitation the rights
9
- ## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- ## copies of the Software, and to permit persons to whom the Software is
11
- ## furnished to do so, subject to the following conditions:
12
- ##
13
- ## The above copyright notice and this permission notice shall be included in
14
- ## all copies or substantial portions of the Software.
15
- ##
16
- ## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- ## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- ## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- ## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- ## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- ## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
- ## THE SOFTWARE.
23
- ##
24
- ## -------------------------------------------------------------------
25
-
26
-
27
1
  module Patron
28
2
 
29
3
  # Base class for Patron exceptions.
@@ -1,29 +1,3 @@
1
- ## -------------------------------------------------------------------
2
- ##
3
- ## Patron HTTP Client: Request class
4
- ## Copyright (c) 2008 The Hive http://www.thehive.com/
5
- ##
6
- ## Permission is hereby granted, free of charge, to any person obtaining a copy
7
- ## of this software and associated documentation files (the "Software"), to deal
8
- ## in the Software without restriction, including without limitation the rights
9
- ## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- ## copies of the Software, and to permit persons to whom the Software is
11
- ## furnished to do so, subject to the following conditions:
12
- ##
13
- ## The above copyright notice and this permission notice shall be included in
14
- ## all copies or substantial portions of the Software.
15
- ##
16
- ## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- ## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- ## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- ## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- ## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- ## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
- ## THE SOFTWARE.
23
- ##
24
- ## -------------------------------------------------------------------
25
-
26
-
27
1
  require 'patron/util'
28
2
 
29
3
  module Patron
@@ -50,12 +24,14 @@ module Patron
50
24
  :url, :username, :password, :file_name, :proxy, :proxy_type, :insecure,
51
25
  :ignore_content_length, :multipart, :action, :timeout, :connect_timeout,
52
26
  :max_redirects, :headers, :auth_type, :upload_data, :buffer_size, :cacert,
53
- :ssl_version, :http_version, :automatic_content_encoding, :force_ipv4, :download_byte_limit
27
+ :ssl_version, :http_version, :automatic_content_encoding, :force_ipv4, :download_byte_limit,
28
+ :low_speed_time, :low_speed_limit
54
29
  ]
55
30
 
56
31
  WRITER_VARS = [
57
32
  :url, :username, :password, :file_name, :proxy, :proxy_type, :insecure,
58
- :ignore_content_length, :multipart, :cacert, :ssl_version, :http_version, :automatic_content_encoding, :force_ipv4, :download_byte_limit
33
+ :ignore_content_length, :multipart, :cacert, :ssl_version, :http_version, :automatic_content_encoding, :force_ipv4, :download_byte_limit,
34
+ :low_speed_time, :low_speed_limit
59
35
  ]
60
36
 
61
37
  attr_reader *READER_VARS
@@ -1,29 +1,3 @@
1
- ## -------------------------------------------------------------------
2
- ##
3
- ## Patron HTTP Client: Response class
4
- ## Copyright (c) 2008 The Hive http://www.thehive.com/
5
- ##
6
- ## Permission is hereby granted, free of charge, to any person obtaining a copy
7
- ## of this software and associated documentation files (the "Software"), to deal
8
- ## in the Software without restriction, including without limitation the rights
9
- ## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- ## copies of the Software, and to permit persons to whom the Software is
11
- ## furnished to do so, subject to the following conditions:
12
- ##
13
- ## The above copyright notice and this permission notice shall be included in
14
- ## all copies or substantial portions of the Software.
15
- ##
16
- ## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- ## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- ## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- ## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- ## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- ## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
- ## THE SOFTWARE.
23
- ##
24
- ## -------------------------------------------------------------------
25
-
26
-
27
1
  module Patron
28
2
 
29
3
  # Represents the response from the HTTP server.
@@ -1,29 +1,3 @@
1
- ## -------------------------------------------------------------------
2
- ##
3
- ## Patron HTTP Client: Response class
4
- ## Copyright (c) 2008 The Hive http://www.thehive.com/
5
- ##
6
- ## Permission is hereby granted, free of charge, to any person obtaining a copy
7
- ## of this software and associated documentation files (the "Software"), to deal
8
- ## in the Software without restriction, including without limitation the rights
9
- ## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- ## copies of the Software, and to permit persons to whom the Software is
11
- ## furnished to do so, subject to the following conditions:
12
- ##
13
- ## The above copyright notice and this permission notice shall be included in
14
- ## all copies or substantial portions of the Software.
15
- ##
16
- ## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- ## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- ## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- ## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- ## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- ## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
- ## THE SOFTWARE.
23
- ##
24
- ## -------------------------------------------------------------------
25
-
26
-
27
1
  module Patron
28
2
  # Contains methods used for decoding the HTTP response body. These are only ever used internally
29
3
  # by the Response class.
@@ -1,29 +1,3 @@
1
- ## -------------------------------------------------------------------
2
- ##
3
- ## Patron HTTP Client: Session class
4
- ## Copyright (c) 2008 The Hive http://www.thehive.com/
5
- ##
6
- ## Permission is hereby granted, free of charge, to any person obtaining a copy
7
- ## of this software and associated documentation files (the "Software"), to deal
8
- ## in the Software without restriction, including without limitation the rights
9
- ## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- ## copies of the Software, and to permit persons to whom the Software is
11
- ## furnished to do so, subject to the following conditions:
12
- ##
13
- ## The above copyright notice and this permission notice shall be included in
14
- ## all copies or substantial portions of the Software.
15
- ##
16
- ## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- ## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- ## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- ## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- ## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- ## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
- ## THE SOFTWARE.
23
- ##
24
- ## -------------------------------------------------------------------
25
-
26
-
27
1
  require 'uri'
28
2
  require 'patron/error'
29
3
  require 'patron/request'
@@ -110,11 +84,21 @@ module Patron
110
84
  # @return [Boolean] Support automatic Content-Encoding decompression and set liberal Accept-Encoding headers
111
85
  attr_accessor :automatic_content_encoding
112
86
 
113
- # @return [Fixnum, nil] Limit the amount of bytes downloaded. If it is set to nil
87
+ # @return [Fixnum, nil] the amount of bytes downloaded. If it is set to nil
114
88
  # (default) no limit will be applied.
115
89
  # **Note that this only works on libCURL 7.34 and newer**
116
90
  attr_accessor :download_byte_limit
117
91
 
92
+ # @return [Integer, nil] the time in number seconds that the transfer speed should be below the
93
+ # `low_speed_limit` for the library to consider it too slow and abort.
94
+ # @see low_speed_limit
95
+ attr_accessor :low_speed_time
96
+
97
+ # @return [Integer, nil] the average transfer speed in bytes per second that the transfer should be below
98
+ # during `low_speed_time` seconds for libcurl to consider it to be too slow and abort.
99
+ # @see low_speed_time
100
+ attr_accessor :low_speed_limit
101
+
118
102
  private :handle_request, :add_cookie_file, :set_debug_file
119
103
 
120
104
  # Create a new Session object for performing requests.
@@ -371,6 +355,8 @@ module Patron
371
355
  req.automatic_content_encoding = options.fetch :automatic_content_encoding, self.automatic_content_encoding
372
356
  req.timeout = options.fetch :timeout, self.timeout
373
357
  req.connect_timeout = options.fetch :connect_timeout, self.connect_timeout
358
+ req.low_speed_time = options.fetch :low_speed_time, self.low_speed_time
359
+ req.low_speed_limit = options.fetch :low_speed_limit, self.low_speed_limit
374
360
  req.force_ipv4 = options.fetch :force_ipv4, self.force_ipv4
375
361
  req.max_redirects = options.fetch :max_redirects, self.max_redirects
376
362
  req.username = options.fetch :username, self.username
@@ -1,29 +1,3 @@
1
- ## -------------------------------------------------------------------
2
- ##
3
- ## Patron HTTP Client: Request class
4
- ## Copyright (c) 2008 The Hive http://www.thehive.com/
5
- ##
6
- ## Permission is hereby granted, free of charge, to any person obtaining a copy
7
- ## of this software and associated documentation files (the "Software"), to deal
8
- ## in the Software without restriction, including without limitation the rights
9
- ## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- ## copies of the Software, and to permit persons to whom the Software is
11
- ## furnished to do so, subject to the following conditions:
12
- ##
13
- ## The above copyright notice and this permission notice shall be included in
14
- ## all copies or substantial portions of the Software.
15
- ##
16
- ## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- ## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- ## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- ## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- ## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- ## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
- ## THE SOFTWARE.
23
- ##
24
- ## -------------------------------------------------------------------
25
-
26
-
27
1
  module Patron
28
2
  module Util
29
3
  extend self
@@ -1,3 +1,3 @@
1
1
  module Patron
2
- VERSION = "0.9.1"
2
+ VERSION = "0.10.0"
3
3
  end
@@ -1,28 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- ## -------------------------------------------------------------------
3
- ##
4
- ## Patron HTTP Client: HTTP test server for integration tests
5
- ## Copyright (c) 2008 The Hive http://www.thehive.com/
6
- ##
7
- ## Permission is hereby granted, free of charge, to any person obtaining a copy
8
- ## of this software and associated documentation files (the "Software"), to deal
9
- ## in the Software without restriction, including without limitation the rights
10
- ## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- ## copies of the Software, and to permit persons to whom the Software is
12
- ## furnished to do so, subject to the following conditions:
13
- ##
14
- ## The above copyright notice and this permission notice shall be included in
15
- ## all copies or substantial portions of the Software.
16
- ##
17
- ## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- ## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- ## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- ## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- ## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
- ## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
- ## THE SOFTWARE.
24
- ##
25
- ## -------------------------------------------------------------------
2
+ # HTTP test server for integration tests
26
3
 
27
4
  root = File.expand_path('../..', __FILE__)
28
5
  require File.join(root, %w[spec support test_server.rb])
@@ -1,28 +1,3 @@
1
- ## -------------------------------------------------------------------
2
- ##
3
- ## Copyright (c) 2008 The Hive http://www.thehive.com/
4
- ##
5
- ## Permission is hereby granted, free of charge, to any person obtaining a copy
6
- ## of this software and associated documentation files (the "Software"), to deal
7
- ## in the Software without restriction, including without limitation the rights
8
- ## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- ## copies of the Software, and to permit persons to whom the Software is
10
- ## furnished to do so, subject to the following conditions:
11
- ##
12
- ## The above copyright notice and this permission notice shall be included in
13
- ## all copies or substantial portions of the Software.
14
- ##
15
- ## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- ## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- ## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- ## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- ## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- ## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- ## THE SOFTWARE.
22
- ##
23
- ## -------------------------------------------------------------------
24
-
25
-
26
1
  require File.expand_path("./spec") + '/spec_helper.rb'
27
2
 
28
3
  describe Patron do
@@ -1,28 +1,3 @@
1
- ## -------------------------------------------------------------------
2
- ##
3
- ## Copyright (c) 2008 The Hive http://www.thehive.com/
4
- ##
5
- ## Permission is hereby granted, free of charge, to any person obtaining a copy
6
- ## of this software and associated documentation files (the "Software"), to deal
7
- ## in the Software without restriction, including without limitation the rights
8
- ## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- ## copies of the Software, and to permit persons to whom the Software is
10
- ## furnished to do so, subject to the following conditions:
11
- ##
12
- ## The above copyright notice and this permission notice shall be included in
13
- ## all copies or substantial portions of the Software.
14
- ##
15
- ## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- ## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- ## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- ## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- ## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- ## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- ## THE SOFTWARE.
22
- ##
23
- ## -------------------------------------------------------------------
24
-
25
-
26
1
  require File.expand_path("./spec") + '/spec_helper.rb'
27
2
 
28
3
 
@@ -24,8 +24,6 @@
24
24
  ## THE SOFTWARE.
25
25
  ##
26
26
  ## -------------------------------------------------------------------
27
-
28
-
29
27
  require File.expand_path("./spec") + '/spec_helper.rb'
30
28
  require 'webrick'
31
29
  require 'base64'
@@ -1,28 +1,3 @@
1
- ## -------------------------------------------------------------------
2
- ##
3
- ## Copyright (c) 2008 The Hive http://www.thehive.com/
4
- ##
5
- ## Permission is hereby granted, free of charge, to any person obtaining a copy
6
- ## of this software and associated documentation files (the "Software"), to deal
7
- ## in the Software without restriction, including without limitation the rights
8
- ## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- ## copies of the Software, and to permit persons to whom the Software is
10
- ## furnished to do so, subject to the following conditions:
11
- ##
12
- ## The above copyright notice and this permission notice shall be included in
13
- ## all copies or substantial portions of the Software.
14
- ##
15
- ## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- ## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- ## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- ## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- ## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- ## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- ## THE SOFTWARE.
22
- ##
23
- ## -------------------------------------------------------------------
24
-
25
-
26
1
  require File.expand_path("./spec") + '/spec_helper.rb'
27
2
  require 'webrick'
28
3
  require 'yaml'
@@ -196,6 +171,13 @@ describe Patron::Session do
196
171
  expect {@session.get("/timeout")}.to raise_error(Patron::TimeoutError)
197
172
  end
198
173
 
174
+ it "should raise an exception on timeout when reading from a slow resource" do
175
+ @session.timeout = 40
176
+ @session.low_speed_time = 2
177
+ @session.low_speed_limit = 10
178
+ expect {@session.get("/slow")}.to raise_error(Patron::TimeoutError)
179
+ end
180
+
199
181
  it "should follow redirects by default" do
200
182
  @session.max_redirects = 1
201
183
  response = @session.get("/redirect")
@@ -1,28 +1,3 @@
1
- ## -------------------------------------------------------------------
2
- ##
3
- ## Copyright (c) 2008 The Hive http://www.thehive.com/
4
- ##
5
- ## Permission is hereby granted, free of charge, to any person obtaining a copy
6
- ## of this software and associated documentation files (the "Software"), to deal
7
- ## in the Software without restriction, including without limitation the rights
8
- ## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- ## copies of the Software, and to permit persons to whom the Software is
10
- ## furnished to do so, subject to the following conditions:
11
- ##
12
- ## The above copyright notice and this permission notice shall be included in
13
- ## all copies or substantial portions of the Software.
14
- ##
15
- ## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- ## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- ## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- ## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- ## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- ## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- ## THE SOFTWARE.
22
- ##
23
- ## -------------------------------------------------------------------
24
-
25
-
26
1
  require File.expand_path("./spec") + '/spec_helper.rb'
27
2
  require 'webrick'
28
3
  require 'yaml'
@@ -1,35 +1,9 @@
1
- ## -------------------------------------------------------------------
2
- ##
3
- ## Copyright (c) 2008 The Hive http://www.thehive.com/
4
- ##
5
- ## Permission is hereby granted, free of charge, to any person obtaining a copy
6
- ## of this software and associated documentation files (the "Software"), to deal
7
- ## in the Software without restriction, including without limitation the rights
8
- ## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- ## copies of the Software, and to permit persons to whom the Software is
10
- ## furnished to do so, subject to the following conditions:
11
- ##
12
- ## The above copyright notice and this permission notice shall be included in
13
- ## all copies or substantial portions of the Software.
14
- ##
15
- ## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- ## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- ## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- ## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- ## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- ## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- ## THE SOFTWARE.
22
- ##
23
- ## -------------------------------------------------------------------
24
-
25
-
26
1
  if ENV["COVERAGE"]
27
2
  require 'simplecov'
28
3
  SimpleCov.start do
29
4
  add_filter "/spec/"
30
5
  end
31
6
  end
32
-
33
7
  require 'rspec'
34
8
 
35
9
  # Kill warnings that not raising a specific exception still allows the method
@@ -1,28 +1,6 @@
1
1
  ## -------------------------------------------------------------------
2
2
  ##
3
3
  ## Patron HTTP Client: HTTP test server for integration tests
4
- ## Copyright (c) 2008 The Hive http://www.thehive.com/
5
- ##
6
- ## Permission is hereby granted, free of charge, to any person obtaining a copy
7
- ## of this software and associated documentation files (the "Software"), to deal
8
- ## in the Software without restriction, including without limitation the rights
9
- ## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- ## copies of the Software, and to permit persons to whom the Software is
11
- ## furnished to do so, subject to the following conditions:
12
- ##
13
- ## The above copyright notice and this permission notice shall be included in
14
- ## all copies or substantial portions of the Software.
15
- ##
16
- ## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- ## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- ## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- ## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- ## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- ## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
- ## THE SOFTWARE.
23
- ##
24
- ## -------------------------------------------------------------------
25
-
26
4
 
27
5
  require 'yaml'
28
6
  require 'webrick'
@@ -102,6 +80,14 @@ class TimeoutServlet < HTTPServlet::AbstractServlet
102
80
  end
103
81
  end
104
82
 
83
+ class SlowServlet < HTTPServlet::AbstractServlet
84
+ def do_GET(req,res)
85
+ sleep 3
86
+ res.header['Content-Type'] = 'text/plain'
87
+ res.body = 'beep'
88
+ end
89
+ end
90
+
105
91
  class RedirectServlet < HTTPServlet::AbstractServlet
106
92
  def do_GET(req,res)
107
93
  res['Location'] = "http://localhost:9001/test"
@@ -203,6 +189,7 @@ class PatronTestServer
203
189
  @server.mount("/testpost", TestPostBodyServlet)
204
190
  @server.mount("/testpatch", TestPatchBodyServlet)
205
191
  @server.mount("/timeout", TimeoutServlet)
192
+ @server.mount("/slow", SlowServlet)
206
193
  @server.mount("/redirect", RedirectServlet)
207
194
  @server.mount("/evil-redirect", EvilRedirectServlet)
208
195
  @server.mount("/picture", PictureServlet)
@@ -1,28 +1,3 @@
1
- ## -------------------------------------------------------------------
2
- ##
3
- ## Copyright (c) 2008 The Hive http://www.thehive.com/
4
- ##
5
- ## Permission is hereby granted, free of charge, to any person obtaining a copy
6
- ## of this software and associated documentation files (the "Software"), to deal
7
- ## in the Software without restriction, including without limitation the rights
8
- ## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- ## copies of the Software, and to permit persons to whom the Software is
10
- ## furnished to do so, subject to the following conditions:
11
- ##
12
- ## The above copyright notice and this permission notice shall be included in
13
- ## all copies or substantial portions of the Software.
14
- ##
15
- ## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- ## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- ## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- ## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- ## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- ## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- ## THE SOFTWARE.
22
- ##
23
- ## -------------------------------------------------------------------
24
-
25
-
26
1
  require File.expand_path("./spec") + '/spec_helper.rb'
27
2
 
28
3
  describe Patron::Util do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: patron
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Phillip Toland
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-07-18 00:00:00.000000000 Z
11
+ date: 2017-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -109,7 +109,6 @@ files:
109
109
  - ".yardopts"
110
110
  - CHANGELOG.md
111
111
  - Gemfile
112
- - Gemfile.lock
113
112
  - LICENSE
114
113
  - README.md
115
114
  - Rakefile
@@ -1,48 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- patron (0.9.1)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- diff-lcs (1.2.5)
10
- docile (1.1.5)
11
- json (2.1.0)
12
- rake (10.4.2)
13
- rake-compiler (0.9.5)
14
- rake
15
- rspec (3.3.0)
16
- rspec-core (~> 3.3.0)
17
- rspec-expectations (~> 3.3.0)
18
- rspec-mocks (~> 3.3.0)
19
- rspec-core (3.3.2)
20
- rspec-support (~> 3.3.0)
21
- rspec-expectations (3.3.1)
22
- diff-lcs (>= 1.2.0, < 2.0)
23
- rspec-support (~> 3.3.0)
24
- rspec-mocks (3.3.2)
25
- diff-lcs (>= 1.2.0, < 2.0)
26
- rspec-support (~> 3.3.0)
27
- rspec-support (3.3.0)
28
- simplecov (0.14.1)
29
- docile (~> 1.1.0)
30
- json (>= 1.8, < 3)
31
- simplecov-html (~> 0.10.0)
32
- simplecov-html (0.10.1)
33
- yard (0.8.7.6)
34
-
35
- PLATFORMS
36
- ruby
37
-
38
- DEPENDENCIES
39
- bundler (>= 1)
40
- patron!
41
- rake (~> 10)
42
- rake-compiler
43
- rspec (>= 2.3.0)
44
- simplecov (~> 0.10)
45
- yard (~> 0.8)
46
-
47
- BUNDLED WITH
48
- 1.14.6