rest-client 1.6.7 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +7 -0
  3. data/.rspec +1 -0
  4. data/.travis.yml +14 -0
  5. data/AUTHORS +81 -0
  6. data/Gemfile +11 -0
  7. data/LICENSE +21 -0
  8. data/README.rdoc +63 -24
  9. data/Rakefile +85 -35
  10. data/bin/restclient +9 -8
  11. data/history.md +63 -1
  12. data/lib/restclient/abstract_response.rb +44 -15
  13. data/lib/restclient/exceptions.rb +20 -10
  14. data/lib/restclient/payload.rb +21 -18
  15. data/lib/restclient/platform.rb +30 -0
  16. data/lib/restclient/raw_response.rb +3 -2
  17. data/lib/restclient/request.rb +368 -63
  18. data/lib/restclient/resource.rb +3 -4
  19. data/lib/restclient/response.rb +2 -5
  20. data/lib/restclient/version.rb +7 -0
  21. data/lib/restclient/windows/root_certs.rb +105 -0
  22. data/lib/restclient/windows.rb +8 -0
  23. data/lib/restclient.rb +6 -15
  24. data/rest-client.gemspec +30 -0
  25. data/rest-client.windows.gemspec +19 -0
  26. data/spec/integration/capath_digicert/244b5494.0 +19 -0
  27. data/spec/integration/capath_digicert/81b9768f.0 +19 -0
  28. data/spec/integration/capath_digicert/README +8 -0
  29. data/spec/integration/capath_digicert/digicert.crt +19 -0
  30. data/spec/integration/capath_verisign/415660c1.0 +14 -0
  31. data/spec/integration/capath_verisign/7651b327.0 +14 -0
  32. data/spec/integration/capath_verisign/README +8 -0
  33. data/spec/integration/capath_verisign/verisign.crt +14 -0
  34. data/spec/integration/certs/digicert.crt +19 -0
  35. data/spec/{integration_spec.rb → integration/integration_spec.rb} +10 -13
  36. data/spec/integration/request_spec.rb +86 -7
  37. data/spec/spec_helper.rb +2 -0
  38. data/spec/{abstract_response_spec.rb → unit/abstract_response_spec.rb} +18 -15
  39. data/spec/{exceptions_spec.rb → unit/exceptions_spec.rb} +17 -20
  40. data/spec/unit/master_shake.jpg +0 -0
  41. data/spec/{payload_spec.rb → unit/payload_spec.rb} +42 -31
  42. data/spec/unit/raw_response_spec.rb +18 -0
  43. data/spec/{request2_spec.rb → unit/request2_spec.rb} +6 -14
  44. data/spec/unit/request_spec.rb +917 -0
  45. data/spec/{resource_spec.rb → unit/resource_spec.rb} +27 -31
  46. data/spec/{response_spec.rb → unit/response_spec.rb} +63 -57
  47. data/spec/{restclient_spec.rb → unit/restclient_spec.rb} +8 -2
  48. data/spec/unit/windows/root_certs_spec.rb +22 -0
  49. metadata +210 -112
  50. data/VERSION +0 -1
  51. data/lib/restclient/net_http_ext.rb +0 -55
  52. data/spec/base.rb +0 -16
  53. data/spec/integration/certs/equifax.crt +0 -19
  54. data/spec/master_shake.jpg +0 -0
  55. data/spec/raw_response_spec.rb +0 -17
  56. data/spec/request_spec.rb +0 -529
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 683937d317980acfcfcfbc94eb76f2566ed3bf92
4
+ data.tar.gz: fa2f669653292404bc814fb436c17755060a75a6
5
+ SHA512:
6
+ metadata.gz: c57e29fbfe2e0bb92cf1556e38438171c04739dc6499098c651021c3e797e7724aa12b70f552d4ad43fe78f7e30d20eeea4b94e29dacb7122d936a253d1d8b98
7
+ data.tar.gz: 234257c6569615bc71b4642c7d2f4850b79bbe5eefc3afc8b62eb899023d3a1e12fd3e81366c356817217b50899c7357fd6a9d16f59819c2ca3a1c0b55e9f480
data/.gitignore ADDED
@@ -0,0 +1,7 @@
1
+ *.gem
2
+ /Gemfile.lock
3
+ /.bundle
4
+ /vendor
5
+ /doc
6
+ /pkg
7
+ /rdoc
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour --format progress --order random
data/.travis.yml ADDED
@@ -0,0 +1,14 @@
1
+ language: ruby
2
+ rvm:
3
+ - "1.9.2"
4
+ - "1.9.3"
5
+ - "2.0.0"
6
+ # Forgo 2.1.0 until Travis has a satisfactory fix for
7
+ # https://github.com/travis-ci/travis-ci/issues/2220
8
+ - "2.1" # always the latest 2.1.x
9
+ - "jruby-19mode"
10
+ script:
11
+ bundle exec rake test
12
+ branches:
13
+ except:
14
+ - "readme-edits"
data/AUTHORS ADDED
@@ -0,0 +1,81 @@
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 Frohoff
15
+ Chris Green
16
+ Coda Hale
17
+ Crawford
18
+ Cyril Rohr
19
+ Dan Mayer
20
+ David Backeus
21
+ David Perkowski
22
+ Dmitri Dolguikh
23
+ Dusty Doris
24
+ Dylan Egan
25
+ El Draper
26
+ Evan Smith
27
+ François Beausoleil
28
+ Gabriele Cirulli
29
+ Garry Shutler
30
+ Giovanni Cappellotto
31
+ Greg Borenstein
32
+ Harm Aarts
33
+ Hiro Asari
34
+ Hugh McGowan
35
+ Ian Warshak
36
+ Ivan Makfinsky
37
+ JH. Chabran
38
+ James Edward Gray II
39
+ Jari Bakken
40
+ Jeff Remer
41
+ Jeffrey Hardy
42
+ Jeremy Kemper
43
+ John Barnette
44
+ Jon Rowe
45
+ Jordi Massaguer Pla
46
+ Juan Alvarez
47
+ Julien Kirch
48
+ Justin Coyne
49
+ Justin Lambert
50
+ Keith Rarick
51
+ Kenichi Kamiya
52
+ Kevin Read
53
+ Kosuke Asami
54
+ Kyle VanderBeek
55
+ Lars Gierth
56
+ Lawrence Leonard Gilbert
57
+ Lee Jarvis
58
+ Lennon Day-Reynolds
59
+ Marc-André Cournoyer
60
+ Matthew Manning
61
+ Michael Klett
62
+ Mike Fletcher
63
+ Nicholas Wieland
64
+ Nick Plante
65
+ Niko Dittmann
66
+ Oscar Del Ben
67
+ Pablo Astigarraga
68
+ Paul Dlug
69
+ Pedro Belo
70
+ Philip Corliss
71
+ Pierre-Louis Gottfrois
72
+ Rafael Ssouza
73
+ Rick "technoweenie"
74
+ Robert Eanes
75
+ Rodrigo Panachi
76
+ Syl Turner
77
+ T. Watanabe
78
+ Tekin
79
+ W. Andrew Loe III
80
+ Waynn Lue
81
+ tpresa
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source "https://rubygems.org"
2
+
3
+ if !!File::ALT_SEPARATOR
4
+ gemspec :name => 'rest-client.windows'
5
+ else
6
+ gemspec :name => 'rest-client'
7
+ end
8
+
9
+ group :test do
10
+ gem 'rake'
11
+ end
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2008-2014 Rest Client Authors
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 all
13
+ 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 THE
21
+ SOFTWARE.
data/README.rdoc CHANGED
@@ -1,11 +1,34 @@
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.svg?branch=master" alt="Build Status" />}[https://travis-ci.org/rest-client/rest-client]
4
+
3
5
  A simple HTTP and REST client for Ruby, inspired by the Sinatra's microframework style
4
6
  of specifying actions: get, put, post, delete.
5
7
 
6
- * Main page: http://github.com/archiloque/rest-client
8
+ * Main page: https://github.com/rest-client/rest-client
7
9
  * Mailing list: rest.client@librelist.com (send a mail to subscribe).
8
10
 
11
+ == Requirements
12
+
13
+ MRI Ruby 1.9.2 and newer are supported. Alternative interpreters compatible with
14
+ 1.9.1+ should work as well.
15
+
16
+ Ruby 1.8.7 is no longer supported. That's because the Ruby 1.8.7 interpreter
17
+ itself no longer has official support, _not_ _even_ _security_ _patches!_ If you
18
+ have been putting off upgrading your servers, now is the time.
19
+ ({More info is on the Ruby developers'
20
+ blog.}[http://www.ruby-lang.org/en/news/2013/06/30/we-retire-1-8-7/])
21
+
22
+ The rest-client gem depends on these other gems for installation and usage:
23
+
24
+ * {mime-types}[http://rubygems.org/gems/mime-types]
25
+ * {netrc}[http://rubygems.org/gems/netrc]
26
+ * {rdoc}[http://rubygems.org/gems/rdoc]
27
+
28
+ If you want to hack on the code, you should also have {the Bundler
29
+ gem}[http://bundler.io/] installed so it can manage all necessary development
30
+ dependencies for you.
31
+
9
32
  == Usage: Raw URL
10
33
 
11
34
  require 'rest_client'
@@ -57,7 +80,7 @@ This does two things for you:
57
80
 
58
81
  If you are sending params that do not contain a File object but the payload needs to be multipart then:
59
82
 
60
- RestClient.post '/data', :foo => 'bar', :multipart => true
83
+ RestClient.post '/data', {:foo => 'bar', :multipart => true}
61
84
 
62
85
  == Usage: ActiveResource-Style
63
86
 
@@ -78,10 +101,10 @@ See RestClient::Resource docs for details.
78
101
 
79
102
  == Exceptions (see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html)
80
103
 
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
104
+ * for result codes between 200 and 207, a RestClient::Response will be returned
105
+ * for result codes 301, 302 or 307, the redirection will be followed if the request is a GET or a HEAD
106
+ * for result code 303, the redirection will be followed and the request transformed into a GET
107
+ * for other cases, a RestClient::Exception holding the Response will be raised; a specific exception class will be thrown for known error codes
85
108
 
86
109
  RestClient.get 'http://example.com/resource'
87
110
  ➔ RestClient::ResourceNotFound: RestClient::ResourceNotFound
@@ -95,7 +118,7 @@ See RestClient::Resource docs for details.
95
118
 
96
119
  == Result handling
97
120
 
98
- A block can be passed to the RestClient method, this block will then be called with the Response.
121
+ A block can be passed to the RestClient method. This block will then be called with the Response.
99
122
  Response.return! can be called to invoke the default response's behavior.
100
123
 
101
124
  # Don't raise exceptions but return the response
@@ -127,24 +150,25 @@ Response.return! can be called to invoke the default response's behavior.
127
150
  end
128
151
  }
129
152
 
130
- == Non-normalized URIs.
153
+ == Non-normalized URIs
131
154
 
132
- If you want to use non-normalized URIs, you can normalize them with the addressable gem (http://addressable.rubyforge.org/api/).
155
+ If you need to normalize URIs, e.g. to work with International Resource Identifiers (IRIs),
156
+ use the addressable gem (http://addressable.rubyforge.org/api/) in your code:
133
157
 
134
158
  require 'addressable/uri'
135
159
  RestClient.get(Addressable::URI.parse("http://www.詹姆斯.com/").normalize.to_str)
136
160
 
137
161
  == Lower-level access
138
162
 
139
- For cases not covered by the general API, you can use the RestClient::Request class which provide a lower-level API.
163
+ For cases not covered by the general API, you can use the RestClient::Request class, which provides a lower-level API.
140
164
 
141
165
  You can:
142
166
 
143
167
  * specify ssl parameters
144
168
  * override cookies
145
- * manually handle the response (so you can operate on the response stream than reading it fully in memory)
169
+ * manually handle the response (e.g. to operate on it as a stream rather than reading it all into memory)
146
170
 
147
- see the class' rdoc for more information.
171
+ See RestClient::Request's documentation for more information.
148
172
 
149
173
  == Shell
150
174
 
@@ -186,10 +210,10 @@ Use as a one-off, curl-style:
186
210
 
187
211
  == Logging
188
212
 
189
- To enable logging you can
213
+ To enable logging you can:
190
214
 
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"):
215
+ * set RestClient.log with a Ruby Logger, or
216
+ * set an environment variable to avoid modifying the code (in this case you can use a file name, "stdout" or "stderr"):
193
217
 
194
218
  $ RESTCLIENT_LOG=stdout path/to/my/program
195
219
 
@@ -212,7 +236,7 @@ RestClient.proxy:
212
236
  RestClient.get "http://some/resource"
213
237
  # => response from some/resource as proxied through proxy.example.com
214
238
 
215
- Often the proxy url is set in an environment variable, so you can do this to
239
+ Often the proxy URL is set in an environment variable, so you can do this to
216
240
  use whatever proxy the system is configured to use:
217
241
 
218
242
  RestClient.proxy = ENV['http_proxy']
@@ -220,8 +244,7 @@ use whatever proxy the system is configured to use:
220
244
  == Query parameters
221
245
 
222
246
  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:
247
+ the URL for GET, HEAD and DELETE requests, escaping the keys and values as needed:
225
248
 
226
249
  RestClient.get 'http://example.com/resource', :params => {:foo => 'bar', :baz => 'qux'}
227
250
  # will GET http://example.com/resource?foo=bar&baz=qux
@@ -256,11 +279,12 @@ Self-signed certificates can be generated with the openssl command-line tool.
256
279
 
257
280
  == Hook
258
281
 
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.
282
+ RestClient.add_before_execution_proc add a Proc to be called before each execution.
283
+ It's handy if you need direct access to the HTTP request.
260
284
 
261
285
  Example:
262
286
 
263
- # Add oath support using the oauth gem
287
+ # Add oauth support using the oauth gem
264
288
  require 'oauth'
265
289
  access_token = ...
266
290
 
@@ -272,14 +296,29 @@ Example:
272
296
 
273
297
  == More
274
298
 
275
- Need caching, more advanced logging or any ability provided by a rack middleware ?
299
+ Need caching, more advanced logging or any ability provided by Rack middleware?
276
300
 
277
- Have a look at rest-client-components http://github.com/crohr/rest-client-components
301
+ Have a look at rest-client-components: http://github.com/crohr/rest-client-components
278
302
 
279
- == Meta
303
+ == Credits
280
304
 
281
- Written by Adam Wiggins, major modifications by Blake Mizerany, maintained by Julien Kirch
305
+ REST Client Team:: Matthew Manning, Lawrence Leonard Gilbert, Andy Brody
306
+
307
+ Creator:: Adam Wiggins
308
+
309
+ Maintainer Emeritus:: Julien Kirch
310
+
311
+ Major contributions:: Blake Mizerany, Julien Kirch
282
312
 
283
313
  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
314
 
315
+ == Legal
316
+
285
317
  Released under the MIT License: http://www.opensource.org/licenses/mit-license.php
318
+
319
+ "Master Shake" photo (http://www.flickr.com/photos/solgrundy/924205581/) by
320
+ "SolGrundy"; used under terms of the Creative Commons Attribution-ShareAlike 2.0
321
+ Generic license (http://creativecommons.org/licenses/by-sa/2.0/)
322
+
323
+ Code for reading Windows root certificate store derived from work by Puppet;
324
+ used under terms of the Apache License, Version 2.0.
data/Rakefile CHANGED
@@ -1,59 +1,110 @@
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']
18
- end
1
+ # load `rake build/install/release tasks'
2
+ require 'bundler/setup'
3
+ require_relative './lib/restclient/version'
19
4
 
20
- ############################
5
+ namespace :ruby do
6
+ Bundler::GemHelper.install_tasks(:name => 'rest-client')
7
+ end
21
8
 
22
- require 'spec/rake/spectask'
9
+ require "rspec/core/rake_task"
23
10
 
24
11
  desc "Run all specs"
25
- task :spec => ["spec:unit", "spec:integration"]
12
+ RSpec::Core::RakeTask.new('spec')
26
13
 
27
14
  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']
15
+ RSpec::Core::RakeTask.new('spec:unit') do |t|
16
+ t.pattern = 'spec/unit/*_spec.rb'
31
17
  end
32
18
 
33
19
  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']
20
+ RSpec::Core::RakeTask.new('spec:integration') do |t|
21
+ t.pattern = 'spec/integration/*_spec.rb'
37
22
  end
38
23
 
39
24
  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']
25
+ RSpec::Core::RakeTask.new(:doc) do |t|
26
+ t.rspec_opts = ["--format", "specdoc", "--dry-run"]
27
+ t.pattern = 'spec/**/*_spec.rb'
43
28
  end
44
29
 
45
30
  desc "Run all examples with RCov"
46
- Spec::Rake::SpecTask.new('rcov') do |t|
47
- t.spec_files = FileList['spec/*_spec.rb']
31
+ RSpec::Core::RakeTask.new('rcov') do |t|
32
+ t.pattern = 'spec/*_spec.rb'
48
33
  t.rcov = true
49
34
  t.rcov_opts = ['--exclude', 'examples']
50
35
  end
51
36
 
52
- task :default => :spec
37
+ task :default do
38
+ sh 'rake -T'
39
+ end
40
+
41
+ def alias_task(alias_task, original)
42
+ desc "Alias for rake #{original}"
43
+ task alias_task, Rake.application[original].arg_names => original
44
+ end
45
+ alias_task(:test, :spec)
53
46
 
54
47
  ############################
55
48
 
56
- require 'rake/rdoctask'
49
+ WindowsPlatforms = %w{x86-mingw32 x64-mingw32 x86-mswin32}
50
+
51
+ namespace :all do
52
+
53
+ desc "Build rest-client #{RestClient::VERSION} for all platforms"
54
+ task :build => ['ruby:build'] + \
55
+ WindowsPlatforms.map {|p| "windows:#{p}:build"}
56
+
57
+ desc "Create tag v#{RestClient::VERSION} and for all platforms build and push " \
58
+ "rest-client #{RestClient::VERSION} to Rubygems"
59
+ task :release => ['build', 'ruby:release'] + \
60
+ WindowsPlatforms.map {|p| "windows:#{p}:push"}
61
+
62
+ end
63
+
64
+ namespace :windows do
65
+ spec_path = File.join(File.dirname(__FILE__), 'rest-client.windows.gemspec')
66
+
67
+ WindowsPlatforms.each do |platform|
68
+ namespace platform do
69
+ gem_filename = "rest-client-#{RestClient::VERSION}-#{platform}.gem"
70
+ base = File.dirname(__FILE__)
71
+ pkg_dir = File.join(base, 'pkg')
72
+ gem_file_path = File.join(pkg_dir, gem_filename)
73
+
74
+ desc "Build #{gem_filename} into the pkg directory"
75
+ task 'build' do
76
+ orig_platform = ENV['BUILD_PLATFORM']
77
+ begin
78
+ ENV['BUILD_PLATFORM'] = platform
79
+
80
+ sh("gem build -V #{spec_path}") do |ok, res|
81
+ if ok
82
+ FileUtils.mkdir_p(pkg_dir)
83
+ FileUtils.mv(File.join(base, gem_filename), pkg_dir)
84
+ Bundler.ui.confirm("rest-client #{RestClient::VERSION} " \
85
+ "built to pkg/#{gem_filename}")
86
+ else
87
+ abort "Command `gem build` failed: #{res}"
88
+ end
89
+ end
90
+
91
+ ensure
92
+ ENV['BUILD_PLATFORM'] = orig_platform
93
+ end
94
+ end
95
+
96
+ desc "Push #{gem_filename} to Rubygems"
97
+ task 'push' do
98
+ sh("gem push #{gem_file_path}")
99
+ end
100
+ end
101
+ end
102
+
103
+ end
104
+
105
+ ############################
106
+
107
+ require 'rdoc/task'
57
108
 
58
109
  Rake::RDocTask.new do |t|
59
110
  t.rdoc_dir = 'rdoc'
@@ -63,4 +114,3 @@ Rake::RDocTask.new do |t|
63
114
  t.rdoc_files.include('README.rdoc')
64
115
  t.rdoc_files.include('lib/*.rb')
65
116
  end
66
-
data/bin/restclient CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- $:.unshift File.dirname(__FILE__) + "/../lib"
3
+ $LOAD_PATH.unshift File.dirname(__FILE__) + "/../lib"
4
4
 
5
5
  require 'rubygems'
6
6
  require 'restclient'
@@ -26,10 +26,10 @@ end
26
26
 
27
27
  config = YAML.load(File.read(ENV['HOME'] + "/.restclient")) rescue {}
28
28
 
29
- @url, @username, @password = if c = config[@url]
30
- [c['url'], c['username'], c['password']]
29
+ if (c = config[@url])
30
+ @url, @username, @password = [c['url'], c['username'], c['password']]
31
31
  else
32
- [@url, * ARGV]
32
+ @url, @username, @password = [@url, * ARGV]
33
33
  end
34
34
 
35
35
  usage("invalid url '#{@url}") unless @url =~ /^https?/
@@ -50,7 +50,7 @@ if @verb
50
50
  end
51
51
  exit 0
52
52
  rescue RestClient::Exception => e
53
- puts e.response.body if e.respond_to? :response
53
+ puts e.response.body if e.respond_to?(:response) && e.response
54
54
  raise
55
55
  end
56
56
  end
@@ -58,7 +58,7 @@ end
58
58
  POSSIBLE_VERBS.each do |m|
59
59
  eval <<-end_eval
60
60
  def #{m}(path, *args, &b)
61
- r[path].#{m}(*args, &b)
61
+ r[path].#{m}(*args, &b)
62
62
  end
63
63
  end_eval
64
64
  end
@@ -79,11 +79,12 @@ end
79
79
  require 'irb'
80
80
  require 'irb/completion'
81
81
 
82
- if File.exists? ".irbrc"
82
+ if File.exist? ".irbrc"
83
83
  ENV['IRBRC'] = ".irbrc"
84
84
  end
85
85
 
86
- if File.exists?(File.expand_path(rcfile = "~/.restclientrc"))
86
+ rcfile = File.expand_path("~/.restclientrc")
87
+ if File.exist?(rcfile)
87
88
  load(rcfile)
88
89
  end
89
90
 
data/history.md CHANGED
@@ -1,3 +1,65 @@
1
+ # 1.8.0
2
+
3
+ - Security: implement standards compliant cookie handling by adding a
4
+ dependency on http-cookie. This breaks compatibility, but was necessary to
5
+ address a session fixation / cookie disclosure vulnerability.
6
+ (#369 / CVE-2015-1820)
7
+
8
+ Previously, any Set-Cookie headers found in an HTTP 30x response would be
9
+ sent to the redirection target, regardless of domain. Responses now expose a
10
+ cookie jar and respect standards compliant domain / path flags in Set-Cookie
11
+ headers.
12
+
13
+ # 1.7.3
14
+
15
+ - Security: redact password in URI from logs (#349 / OSVDB-117461)
16
+ - Drop monkey patch on MIME::Types (added `type_for_extension` method, use
17
+ the public interface instead.
18
+
19
+ # 1.7.2
20
+
21
+ - Ignore duplicate certificates in CA store on Windows
22
+
23
+ # 1.7.1
24
+
25
+ - Relax mime-types dependency to continue supporting mime-types 1.x series.
26
+ There seem to be a large number of popular gems that have depended on
27
+ mime-types '~> 1.16' until very recently.
28
+ - Improve urlencode performance
29
+ - Clean up a number of style points
30
+
31
+ # 1.7.0
32
+
33
+ - This release drops support for Ruby 1.8.7 and breaks compatibility in a few
34
+ other relatively minor ways
35
+ - Upgrade to mime-types ~> 2.0
36
+ - Don't CGI.unescape cookie values sent to the server (issue #89)
37
+ - Add support for reading credentials from netrc
38
+ - Lots of SSL changes and enhancements: (#268)
39
+ - Enable peer verification by default (setting `VERIFY_PEER` with OpenSSL)
40
+ - By default, use the system default certificate store for SSL verification,
41
+ even on Windows (this uses a separate Windows build that pulls in ffi)
42
+ - Add support for SSL `ca_path`
43
+ - Add support for SSL `cert_store`
44
+ - Add support for SSL `verify_callback` (with some caveats for jruby, OS X, #277)
45
+ - Add support for SSL ciphers, and choose secure ones by default
46
+ - Run tests under travis
47
+ - Several other bugfixes and test improvements
48
+ - Convert Errno::ETIMEDOUT to RestClient::RequestTimeout
49
+ - Handle more HTTP response codes from recent standards
50
+ - Save raw responses to binary mode tempfile (#110)
51
+ - Disable timeouts with :timeout => nil rather than :timeout => -1
52
+ - Drop all Net::HTTP monkey patches
53
+
54
+ # 1.6.8
55
+
56
+ - The 1.6.x series will be the last to support Ruby 1.8.7
57
+ - Pin mime-types to < 2.0 to maintain Ruby 1.8.7 support
58
+ - Add Gemfile, AUTHORS, add license to gemspec
59
+ - Point homepage at https://github.com/rest-client/rest-client
60
+ - Clean up and fix various tests and ruby warnings
61
+ - Backport `ssl_verify_callback` functionality from 1.7.0
62
+
1
63
  # 1.6.7
2
64
 
3
65
  - rebuild with 1.8.7 to avoid https://github.com/rubygems/rubygems/pull/57
@@ -131,4 +193,4 @@ The only breaking change should be the exception classes, but as the new classes
131
193
 
132
194
  All changes exept the last one should be fully compatible with the previous version.
133
195
 
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.
196
+ 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.