rest-client 1.6.7 → 1.6.8.rc1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rest-client might be problematic. Click here for more details.

checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 75648c16a034ceb1e1ffe1d410673fca7382ea4e
4
+ data.tar.gz: c75d6e7774ff6d5193b15b6dda64ef886aed2e99
5
+ SHA512:
6
+ metadata.gz: 0c90bccfeb730812bb349e9b0548290b8c4b76446d56a3f694fe430ae9725a76982ee2194c25e06718d6a284772f14097e20acc65dc24aad8b86df7bc24fe880
7
+ data.tar.gz: 3184b4b9eeff9e639b9ead1024c5b4112457b883a6f188c48821d475baf9705e94f94b77d4bf8e5f3ab007c0b61788268ce369f6a84c772215bb2f8f129af6eb
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ .idea
2
+ .rvmrc
3
+ doc
4
+ rdoc
5
+ pkg
6
+ *.gem
7
+ scratchpad.rb
8
+ /Gemfile.lock
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour --format progress --order random
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - "1.8.7"
data/AUTHORS ADDED
@@ -0,0 +1,75 @@
1
+ The Ruby REST Client would not be what it is today without the help of
2
+ the following kind souls:
3
+
4
+ Adam Jacob
5
+ Adam Wiggins
6
+ Aman Gupta
7
+ Andy Brody
8
+ Blake Mizerany
9
+ Brad Ediger
10
+ Braintree
11
+ Brian Donovan
12
+ Caleb Land
13
+ Chris Dinn
14
+ Chris Green
15
+ Coda Hale
16
+ Crawford
17
+ Cyril Rohr
18
+ Dan Mayer
19
+ David Backeus
20
+ Dmitri Dolguikh
21
+ Dusty Doris
22
+ Dylan Egan
23
+ El Draper
24
+ Evan Smith
25
+ François Beausoleil
26
+ Gabriele Cirulli
27
+ Garry Shutler
28
+ Giovanni Cappellotto
29
+ Greg Borenstein
30
+ Harm Aarts
31
+ Hiro Asari
32
+ Hugh McGowan
33
+ Ian Warshak
34
+ Ivan Makfinsky
35
+ James Edward Gray II
36
+ Jari Bakken
37
+ Jeff Remer
38
+ JH. Chabran
39
+ John Barnette
40
+ Jon Rowe
41
+ Jordi Massaguer Pla
42
+ Juan Alvarez
43
+ Julien Kirch
44
+ Justin Coyne
45
+ Keith Rarick
46
+ Kenichi Kamiya
47
+ Kevin Read
48
+ Kosuke Asami
49
+ Kyle VanderBeek
50
+ Lars Gierth
51
+ Lawrence Leonard Gilbert
52
+ Lee Jarvis
53
+ Lennon Day-Reynolds
54
+ macournoyer
55
+ Matthew Manning
56
+ Michael Klett
57
+ Mike Fletcher
58
+ Nicholas Wieland
59
+ Nick Plante
60
+ Niko Dittmann
61
+ Oscar Del Ben
62
+ Pablo Astigarraga
63
+ Paul Dlug
64
+ Pedro Belo
65
+ rafael.ssouza
66
+ Philip Corliss
67
+ Rick "technoweenie"
68
+ Robert Eanes
69
+ Rodrigo Panachi
70
+ Syl Turner
71
+ T. Watanabe
72
+ Tekin
73
+ tpresa
74
+ W. Andrew Loe III
75
+ Waynn Lue
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ group :test do
6
+ gem 'rake'
7
+ end
data/README.rdoc CHANGED
@@ -1,9 +1,12 @@
1
1
  = REST Client -- simple DSL for accessing HTTP and REST resources
2
2
 
3
+ Build status: {<img src="https://travis-ci.org/rest-client/rest-client.png?branch=1.6-legacy" alt="Build Status" />}[https://travis-ci.org/rest-client/rest-client]
4
+
5
+
3
6
  A simple HTTP and REST client for Ruby, inspired by the Sinatra's microframework style
4
7
  of specifying actions: get, put, post, delete.
5
8
 
6
- * Main page: http://github.com/archiloque/rest-client
9
+ * Main page: https://github.com/rest-client/rest-client
7
10
  * Mailing list: rest.client@librelist.com (send a mail to subscribe).
8
11
 
9
12
  == Usage: Raw URL
@@ -78,10 +81,10 @@ See RestClient::Resource docs for details.
78
81
 
79
82
  == Exceptions (see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html)
80
83
 
81
- * for results code between 200 and 207 a RestClient::Response will be returned
82
- * for results code 301, 302 or 307 the redirection will be followed if the request is a get or a head
83
- * for result code 303 the redirection will be followed and the request transformed into a get
84
- * for other cases a RestClient::Exception holding the Response will be raised, a specific exception class will be thrown for know error codes
84
+ * for result codes between 200 and 207, a RestClient::Response will be returned
85
+ * for result codes 301, 302 or 307, the redirection will be followed if the request is a GET or a HEAD
86
+ * for result code 303, the redirection will be followed and the request transformed into a GET
87
+ * for other cases, a RestClient::Exception holding the Response will be raised; a specific exception class will be thrown for known error codes
85
88
 
86
89
  RestClient.get 'http://example.com/resource'
87
90
  ➔ RestClient::ResourceNotFound: RestClient::ResourceNotFound
@@ -95,7 +98,7 @@ See RestClient::Resource docs for details.
95
98
 
96
99
  == Result handling
97
100
 
98
- A block can be passed to the RestClient method, this block will then be called with the Response.
101
+ A block can be passed to the RestClient method. This block will then be called with the Response.
99
102
  Response.return! can be called to invoke the default response's behavior.
100
103
 
101
104
  # Don't raise exceptions but return the response
@@ -127,24 +130,25 @@ Response.return! can be called to invoke the default response's behavior.
127
130
  end
128
131
  }
129
132
 
130
- == Non-normalized URIs.
133
+ == Non-normalized URIs
131
134
 
132
- If you want to use non-normalized URIs, you can normalize them with the addressable gem (http://addressable.rubyforge.org/api/).
135
+ If you need to normalize URIs, e.g. to work with International Resource Identifiers (IRIs),
136
+ use the addressable gem (http://addressable.rubyforge.org/api/) in your code:
133
137
 
134
138
  require 'addressable/uri'
135
139
  RestClient.get(Addressable::URI.parse("http://www.詹姆斯.com/").normalize.to_str)
136
140
 
137
141
  == Lower-level access
138
142
 
139
- For cases not covered by the general API, you can use the RestClient::Request class which provide a lower-level API.
143
+ For cases not covered by the general API, you can use the RestClient::Request class, which provides a lower-level API.
140
144
 
141
145
  You can:
142
146
 
143
147
  * specify ssl parameters
144
148
  * override cookies
145
- * manually handle the response (so you can operate on the response stream than reading it fully in memory)
149
+ * manually handle the response (e.g. to operate on it as a stream rather than reading it all into memory)
146
150
 
147
- see the class' rdoc for more information.
151
+ See RestClient::Request's documentation for more information.
148
152
 
149
153
  == Shell
150
154
 
@@ -186,10 +190,10 @@ Use as a one-off, curl-style:
186
190
 
187
191
  == Logging
188
192
 
189
- To enable logging you can
193
+ To enable logging you can:
190
194
 
191
- * set RestClient.log with a ruby Logger
192
- * or set an environment variable to avoid modifying the code (in this case you can use a file name, "stdout" or "stderr"):
195
+ * set RestClient.log with a Ruby Logger, or
196
+ * set an environment variable to avoid modifying the code (in this case you can use a file name, "stdout" or "stderr"):
193
197
 
194
198
  $ RESTCLIENT_LOG=stdout path/to/my/program
195
199
 
@@ -212,7 +216,7 @@ RestClient.proxy:
212
216
  RestClient.get "http://some/resource"
213
217
  # => response from some/resource as proxied through proxy.example.com
214
218
 
215
- Often the proxy url is set in an environment variable, so you can do this to
219
+ Often the proxy URL is set in an environment variable, so you can do this to
216
220
  use whatever proxy the system is configured to use:
217
221
 
218
222
  RestClient.proxy = ENV['http_proxy']
@@ -220,8 +224,7 @@ use whatever proxy the system is configured to use:
220
224
  == Query parameters
221
225
 
222
226
  Request objects know about query parameters and will automatically add them to
223
- the url for GET, HEAD and DELETE requests and escape the keys and values as
224
- needed:
227
+ the URL for GET, HEAD and DELETE requests, escaping the keys and values as needed:
225
228
 
226
229
  RestClient.get 'http://example.com/resource', :params => {:foo => 'bar', :baz => 'qux'}
227
230
  # will GET http://example.com/resource?foo=bar&baz=qux
@@ -256,11 +259,12 @@ Self-signed certificates can be generated with the openssl command-line tool.
256
259
 
257
260
  == Hook
258
261
 
259
- RestClient.add_before_execution_proc add a Proc to be called before each execution, it's handy if you need a direct access to the http request.
262
+ RestClient.add_before_execution_proc add a Proc to be called before each execution.
263
+ It's handy if you need direct access to the HTTP request.
260
264
 
261
265
  Example:
262
266
 
263
- # Add oath support using the oauth gem
267
+ # Add oauth support using the oauth gem
264
268
  require 'oauth'
265
269
  access_token = ...
266
270
 
@@ -272,14 +276,26 @@ Example:
272
276
 
273
277
  == More
274
278
 
275
- Need caching, more advanced logging or any ability provided by a rack middleware ?
279
+ Need caching, more advanced logging or any ability provided by Rack middleware?
280
+
281
+ Have a look at rest-client-components: http://github.com/crohr/rest-client-components
282
+
283
+ == Credits
276
284
 
277
- Have a look at rest-client-components http://github.com/crohr/rest-client-components
285
+ REST Client Team:: Matthew Manning, Lawrence Leonard Gilbert, Andy Brody
278
286
 
279
- == Meta
287
+ Creator:: Adam Wiggins
280
288
 
281
- Written by Adam Wiggins, major modifications by Blake Mizerany, maintained by Julien Kirch
289
+ Maintainer Emeritus:: Julien Kirch
290
+
291
+ Major contributions:: Blake Mizerany, Julien Kirch
282
292
 
283
293
  Patches contributed by many, including Chris Anderson, Greg Borenstein, Ardekantur, Pedro Belo, Rafael Souza, Rick Olson, Aman Gupta, François Beausoleil and Nick Plante.
284
294
 
295
+ == Legal
296
+
285
297
  Released under the MIT License: http://www.opensource.org/licenses/mit-license.php
298
+
299
+ "Master Shake" photo (http://www.flickr.com/photos/solgrundy/924205581/) by
300
+ "SolGrundy"; used under terms of the Creative Commons Attribution-ShareAlike 2.0
301
+ Generic license (http://creativecommons.org/licenses/by-sa/2.0/)
data/Rakefile CHANGED
@@ -1,50 +1,33 @@
1
- require 'rake'
2
-
3
- require 'jeweler'
4
-
5
- Jeweler::Tasks.new do |s|
6
- s.name = "rest-client"
7
- s.description = "A simple HTTP and REST client for Ruby, inspired by the Sinatra microframework style of specifying actions: get, put, post, delete."
8
- s.summary = "Simple HTTP and REST client for Ruby, inspired by microframework syntax for specifying actions."
9
- s.authors = ["Adam Wiggins", "Julien Kirch"]
10
- s.email = "rest.client@librelist.com"
11
- s.homepage = "http://github.com/archiloque/rest-client"
12
- s.files = FileList["[A-Z]*", "{bin,lib,spec}/**/*"]
13
- s.test_files = FileList["{spec}/**/*"]
14
- s.add_runtime_dependency("mime-types", ">= 1.16")
15
- s.add_development_dependency("webmock", ">= 0.9.1")
16
- s.add_development_dependency("rspec")
17
- s.extra_rdoc_files = [ 'README.rdoc', 'history.md']
1
+ begin
2
+ # optionally load `rake build/install/release tasks'
3
+ require 'bundler/gem_tasks'
4
+ rescue LoadError
18
5
  end
19
6
 
20
- ############################
21
-
22
- require 'spec/rake/spectask'
7
+ require "rspec/core/rake_task"
23
8
 
24
9
  desc "Run all specs"
25
10
  task :spec => ["spec:unit", "spec:integration"]
26
11
 
27
12
  desc "Run unit specs"
28
- Spec::Rake::SpecTask.new('spec:unit') do |t|
29
- t.spec_opts = ['--colour --format progress --loadby mtime --reverse']
30
- t.spec_files = FileList['spec/*_spec.rb']
13
+ RSpec::Core::RakeTask.new('spec:unit') do |t|
14
+ t.pattern = ['spec/*_spec.rb']
31
15
  end
32
16
 
33
17
  desc "Run integration specs"
34
- Spec::Rake::SpecTask.new('spec:integration') do |t|
35
- t.spec_opts = ['--colour --format progress --loadby mtime --reverse']
36
- t.spec_files = FileList['spec/integration/*_spec.rb']
18
+ RSpec::Core::RakeTask.new('spec:integration') do |t|
19
+ t.pattern = ['spec/integration/*_spec.rb']
37
20
  end
38
21
 
39
22
  desc "Print specdocs"
40
- Spec::Rake::SpecTask.new(:doc) do |t|
41
- t.spec_opts = ["--format", "specdoc", "--dry-run"]
42
- t.spec_files = FileList['spec/*_spec.rb']
23
+ RSpec::Core::RakeTask.new(:doc) do |t|
24
+ t.rspec_opts = ["--format", "specdoc", "--dry-run"]
25
+ t.pattern = ['spec/*_spec.rb']
43
26
  end
44
27
 
45
28
  desc "Run all examples with RCov"
46
- Spec::Rake::SpecTask.new('rcov') do |t|
47
- t.spec_files = FileList['spec/*_spec.rb']
29
+ RSpec::Core::RakeTask.new('rcov') do |t|
30
+ t.pattern = ['spec/*_spec.rb']
48
31
  t.rcov = true
49
32
  t.rcov_opts = ['--exclude', 'examples']
50
33
  end
@@ -53,7 +36,7 @@ task :default => :spec
53
36
 
54
37
  ############################
55
38
 
56
- require 'rake/rdoctask'
39
+ require 'rdoc/task'
57
40
 
58
41
  Rake::RDocTask.new do |t|
59
42
  t.rdoc_dir = 'rdoc'
data/history.md CHANGED
@@ -1,3 +1,12 @@
1
+ # 1.6.8
2
+
3
+ - The 1.6.x series will be the last to support Ruby 1.8.7
4
+ - Pin mime-types to < 2.0 to maintain Ruby 1.8.7 support
5
+ - Add Gemfile, AUTHORS, add license to gemspec
6
+ - Point homepage at https://github.com/rest-client/rest-client
7
+ - Clean up and fix various tests and ruby warnings
8
+ - Backport `ssl_verify_callback` functionality from 1.7.0
9
+
1
10
  # 1.6.7
2
11
 
3
12
  - rebuild with 1.8.7 to avoid https://github.com/rubygems/rubygems/pull/57
@@ -131,4 +140,4 @@ The only breaking change should be the exception classes, but as the new classes
131
140
 
132
141
  All changes exept the last one should be fully compatible with the previous version.
133
142
 
134
- NOTE: due to a dependency problem and to the last change, heroku users should update their heroku gem to >= 1.5.3 to be able to use this version.
143
+ NOTE: due to a dependency problem and to the last change, heroku users should update their heroku gem to >= 1.5.3 to be able to use this version.
data/lib/restclient.rb CHANGED
@@ -9,6 +9,8 @@ rescue LoadError => e
9
9
  raise LoadError, "no such file to load -- net/https. Try running apt-get install libopenssl-ruby"
10
10
  end
11
11
 
12
+ require File.dirname(__FILE__) + '/restclient/version'
13
+ require File.dirname(__FILE__) + '/restclient/platform'
12
14
  require File.dirname(__FILE__) + '/restclient/exceptions'
13
15
  require File.dirname(__FILE__) + '/restclient/request'
14
16
  require File.dirname(__FILE__) + '/restclient/abstract_response'
@@ -103,12 +105,6 @@ module RestClient
103
105
  @@log = create_log log
104
106
  end
105
107
 
106
- def self.version
107
- version_path = File.dirname(__FILE__) + "/../VERSION"
108
- return File.read(version_path).chomp if File.file?(version_path)
109
- "0.0.0"
110
- end
111
-
112
108
  # Create a log that respond to << like a logger
113
109
  # param can be 'stdout', 'stderr', a string (then we will log to that file) or a logger (then we return it)
114
110
  def self.create_log param
@@ -21,7 +21,7 @@ module RestClient
21
21
  305 => 'Use Proxy', # http/1.1
22
22
  306 => 'Switch Proxy', # no longer used
23
23
  307 => 'Temporary Redirect', # http/1.1
24
-
24
+
25
25
  400 => 'Bad Request',
26
26
  401 => 'Unauthorized',
27
27
  402 => 'Payment Required',
@@ -46,7 +46,7 @@ module RestClient
46
46
  423 => 'Locked', #WebDAV
47
47
  424 => 'Failed Dependency', #WebDAV
48
48
  425 => 'Unordered Collection', #WebDAV
49
- 426 => 'Upgrade Required',
49
+ 426 => 'Upgrade Required',
50
50
  449 => 'Retry With', #Microsoft
51
51
  450 => 'Blocked By Windows Parental Controls', #Microsoft
52
52
 
@@ -85,6 +85,7 @@ module RestClient
85
85
 
86
86
  def initialize response = nil, initial_response_code = nil
87
87
  @response = response
88
+ @message = nil
88
89
  @initial_response_code = initial_response_code
89
90
 
90
91
  # compatibility: this make the exception behave like a Net::HTTPResponse
@@ -111,7 +112,7 @@ module RestClient
111
112
  def to_s
112
113
  inspect
113
114
  end
114
-
115
+
115
116
  def message
116
117
  @message || self.class.name
117
118
  end
@@ -154,7 +155,9 @@ module RestClient
154
155
  # A redirect was encountered; caught by execute to retry with the new url.
155
156
  class Redirect < Exception
156
157
 
157
- message = 'Redirect'
158
+ def message
159
+ 'Redirect'
160
+ end
158
161
 
159
162
  attr_accessor :url
160
163
 
@@ -163,8 +166,10 @@ module RestClient
163
166
  end
164
167
  end
165
168
 
166
- class MaxRedirectsReached < Exception
167
- message = 'Maximum number of redirect reached'
169
+ class MaxRedirectsReached < Exception
170
+ def message
171
+ 'Maximum number of redirect reached'
172
+ end
168
173
  end
169
174
 
170
175
  # The server broke the connection prior to the request completing. Usually
@@ -1,6 +1,6 @@
1
1
  module Net
2
- class HTTP
3
-
2
+ class HTTP
3
+
4
4
  # Adding the patch method if it doesn't exist (rest-client issue: https://github.com/archiloque/rest-client/issues/79)
5
5
  if !defined?(Net::HTTP::Patch)
6
6
  # Code taken from this commit: https://github.com/ruby/ruby/commit/ab70e53ac3b5102d4ecbe8f38d4f76afad29d37d#lib/net/http.rb
@@ -10,7 +10,7 @@ module Net
10
10
  def patch(path, data, initheader = nil, dest = nil, &block) # :yield: +body_segment+
11
11
  send_entity(path, data, initheader, dest, Patch, &block)
12
12
  end
13
-
13
+
14
14
  # Executes a request which uses a representation
15
15
  # and returns its body.
16
16
  def send_entity(path, data, initheader, dest, type, &block)
@@ -26,7 +26,7 @@ module Net
26
26
  res
27
27
  end
28
28
  end
29
-
29
+
30
30
  class Patch < HTTPRequest
31
31
  METHOD = 'PATCH'
32
32
  REQUEST_HAS_BODY = true
@@ -38,7 +38,7 @@ module Net
38
38
  # Replace the request method in Net::HTTP to sniff the body type
39
39
  # and set the stream if appropriate
40
40
  #
41
- # Taken from:
41
+ # Taken from:
42
42
  # http://www.missiondata.com/blog/ruby/29/streaming-data-to-s3-with-ruby/
43
43
 
44
44
  alias __request__ request