rest-client 1.7.0-x86-mswin32 → 1.7.1-x86-mswin32
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.
Potentially problematic release.
This version of rest-client might be problematic. Click here for more details.
- data/Rakefile +1 -2
- data/bin/restclient +8 -7
- data/history.md +8 -0
- data/lib/restclient/abstract_response.rb +1 -1
- data/lib/restclient/exceptions.rb +1 -1
- data/lib/restclient/payload.rb +16 -18
- data/lib/restclient/request.rb +17 -12
- data/lib/restclient/resource.rb +3 -4
- data/lib/restclient/response.rb +1 -1
- data/lib/restclient/version.rb +1 -1
- data/rest-client.gemspec +1 -2
- data/spec/spec_helper.rb +0 -10
- data/spec/unit/request2_spec.rb +1 -1
- data/spec/unit/resource_spec.rb +10 -13
- data/spec/unit/response_spec.rb +6 -6
- metadata +13 -7
data/Rakefile
CHANGED
@@ -81,7 +81,7 @@ namespace :windows do
|
|
81
81
|
if ok
|
82
82
|
FileUtils.mkdir_p(pkg_dir)
|
83
83
|
FileUtils.mv(File.join(base, gem_filename), pkg_dir)
|
84
|
-
Bundler.ui.confirm("rest-client #{RestClient::VERSION} "
|
84
|
+
Bundler.ui.confirm("rest-client #{RestClient::VERSION} " \
|
85
85
|
"built to pkg/#{gem_filename}")
|
86
86
|
else
|
87
87
|
abort "Command `gem build` failed: #{res}"
|
@@ -114,4 +114,3 @@ Rake::RDocTask.new do |t|
|
|
114
114
|
t.rdoc_files.include('README.rdoc')
|
115
115
|
t.rdoc_files.include('lib/*.rb')
|
116
116
|
end
|
117
|
-
|
data/bin/restclient
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
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
|
-
|
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?/
|
@@ -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
|
-
|
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.
|
82
|
+
if File.exist? ".irbrc"
|
83
83
|
ENV['IRBRC'] = ".irbrc"
|
84
84
|
end
|
85
85
|
|
86
|
-
|
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,11 @@
|
|
1
|
+
# 1.7.1
|
2
|
+
|
3
|
+
- Relax mime-types dependency to continue supporting mime-types 1.x series.
|
4
|
+
There seem to be a large number of popular gems that have depended on
|
5
|
+
mime-types '~> 1.16' until very recently.
|
6
|
+
- Improve urlencode performance
|
7
|
+
- Clean up a number of style points
|
8
|
+
|
1
9
|
# 1.7.0
|
2
10
|
|
3
11
|
- This release drops support for Ruby 1.8.7 and breaks compatibility in a few
|
@@ -82,7 +82,7 @@ module RestClient
|
|
82
82
|
Request.execute args, &block
|
83
83
|
end
|
84
84
|
|
85
|
-
def
|
85
|
+
def self.beautify_headers(headers)
|
86
86
|
headers.inject({}) do |out, (key, value)|
|
87
87
|
out[key.gsub(/-/, '_').downcase.to_sym] = %w{ set-cookie }.include?(key.downcase) ? value : value.first
|
88
88
|
out
|
@@ -86,7 +86,7 @@ module RestClient
|
|
86
86
|
# probably an HTML error page) is e.response.
|
87
87
|
class Exception < RuntimeError
|
88
88
|
attr_accessor :response
|
89
|
-
attr_writer
|
89
|
+
attr_writer :message
|
90
90
|
|
91
91
|
def initialize response = nil, initial_response_code = nil
|
92
92
|
@response = response
|
data/lib/restclient/payload.rb
CHANGED
@@ -25,12 +25,12 @@ module RestClient
|
|
25
25
|
def has_file?(params)
|
26
26
|
params.any? do |_, v|
|
27
27
|
case v
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
28
|
+
when Hash
|
29
|
+
has_file?(v)
|
30
|
+
when Array
|
31
|
+
has_file_array?(v)
|
32
|
+
else
|
33
|
+
v.respond_to?(:path) && v.respond_to?(:read)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
@@ -38,12 +38,12 @@ module RestClient
|
|
38
38
|
def has_file_array?(params)
|
39
39
|
params.any? do |v|
|
40
40
|
case v
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
41
|
+
when Hash
|
42
|
+
has_file?(v)
|
43
|
+
when Array
|
44
|
+
has_file_array?(v)
|
45
|
+
else
|
46
|
+
v.respond_to?(:path) && v.respond_to?(:read)
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
@@ -147,17 +147,15 @@ module RestClient
|
|
147
147
|
|
148
148
|
# for UrlEncoded escape the keys
|
149
149
|
def handle_key key
|
150
|
-
|
150
|
+
Parser.escape(key.to_s, Escape)
|
151
151
|
end
|
152
152
|
|
153
153
|
def headers
|
154
154
|
super.merge({'Content-Type' => 'application/x-www-form-urlencoded'})
|
155
155
|
end
|
156
156
|
|
157
|
-
|
158
|
-
|
159
|
-
URI.const_defined?(:Parser) ? URI::Parser.new : URI
|
160
|
-
end
|
157
|
+
Parser = URI.const_defined?(:Parser) ? URI::Parser.new : URI
|
158
|
+
Escape = Regexp.new("[^#{URI::PATTERN::UNRESERVED}]")
|
161
159
|
end
|
162
160
|
|
163
161
|
class Multipart < Base
|
@@ -206,7 +204,7 @@ module RestClient
|
|
206
204
|
s.write(" filename=\"#{v.respond_to?(:original_filename) ? v.original_filename : File.basename(v.path)}\"#{EOL}")
|
207
205
|
s.write("Content-Type: #{v.respond_to?(:content_type) ? v.content_type : mime_for(v.path)}#{EOL}")
|
208
206
|
s.write(EOL)
|
209
|
-
while data = v.read(8124)
|
207
|
+
while (data = v.read(8124))
|
210
208
|
s.write(data)
|
211
209
|
end
|
212
210
|
ensure
|
data/lib/restclient/request.rb
CHANGED
@@ -408,7 +408,7 @@ module RestClient
|
|
408
408
|
net.start do |http|
|
409
409
|
if @block_response
|
410
410
|
net_http_do_request(http, req, payload ? payload.to_s : nil,
|
411
|
-
|
411
|
+
&@block_response)
|
412
412
|
else
|
413
413
|
res = net_http_do_request(http, req, payload ? payload.to_s : nil) \
|
414
414
|
{ |http_response| fetch_body(http_response) }
|
@@ -511,20 +511,25 @@ module RestClient
|
|
511
511
|
end
|
512
512
|
|
513
513
|
def log_request
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
514
|
+
return unless RestClient.log
|
515
|
+
|
516
|
+
out = []
|
517
|
+
out << "RestClient.#{method} #{url.inspect}"
|
518
|
+
out << payload.short_inspect if payload
|
519
|
+
out << processed_headers.to_a.sort.map { |(k, v)| [k.inspect, v.inspect].join("=>") }.join(", ")
|
520
|
+
RestClient.log << out.join(', ') + "\n"
|
521
521
|
end
|
522
522
|
|
523
523
|
def log_response res
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
524
|
+
return unless RestClient.log
|
525
|
+
|
526
|
+
size = if @raw_response
|
527
|
+
File.size(@tf.path)
|
528
|
+
else
|
529
|
+
res.body.nil? ? 0 : res.body.size
|
530
|
+
end
|
531
|
+
|
532
|
+
RestClient.log << "# => #{res.code} #{res.class.to_s.gsub(/^Net::HTTP/, '')} | #{(res['Content-type'] || '').gsub(/;.*$/, '')} #{size} bytes\n"
|
528
533
|
end
|
529
534
|
|
530
535
|
# Return a hash of headers whose keys are capitalized strings
|
data/lib/restclient/resource.rb
CHANGED
@@ -149,10 +149,9 @@ module RestClient
|
|
149
149
|
#
|
150
150
|
def [](suburl, &new_block)
|
151
151
|
case
|
152
|
-
|
153
|
-
|
154
|
-
else
|
155
|
-
self.class.new(concat_urls(url, suburl), options)
|
152
|
+
when block_given? then self.class.new(concat_urls(url, suburl), options, &new_block)
|
153
|
+
when block then self.class.new(concat_urls(url, suburl), options, &block)
|
154
|
+
else self.class.new(concat_urls(url, suburl), options)
|
156
155
|
end
|
157
156
|
end
|
158
157
|
|
data/lib/restclient/response.rb
CHANGED
data/lib/restclient/version.rb
CHANGED
data/rest-client.gemspec
CHANGED
@@ -22,9 +22,8 @@ Gem::Specification.new do |s|
|
|
22
22
|
s.add_development_dependency('pry-doc')
|
23
23
|
s.add_development_dependency('rdoc', '>= 2.4.2', '< 5.0')
|
24
24
|
|
25
|
-
s.add_dependency('mime-types', '
|
25
|
+
s.add_dependency('mime-types', '>= 1.16', '< 3.0')
|
26
26
|
s.add_dependency('netrc', '~> 0.7')
|
27
27
|
|
28
28
|
s.required_ruby_version = '>= 1.9.2'
|
29
29
|
end
|
30
|
-
|
data/spec/spec_helper.rb
CHANGED
data/spec/unit/request2_spec.rb
CHANGED
@@ -12,7 +12,7 @@ describe RestClient::Request do
|
|
12
12
|
|
13
13
|
it "can use a block to process response" do
|
14
14
|
response_value = nil
|
15
|
-
block =
|
15
|
+
block = proc do |http_response|
|
16
16
|
response_value = http_response.body
|
17
17
|
end
|
18
18
|
stub_request(:get, 'http://some/resource?a=b&c=d').with(:headers => {'Accept'=>'*/*; q=0.5, application/xml', 'Accept-Encoding'=>'gzip, deflate', 'Foo'=>'bar'}).to_return(:body => 'foo', :status => 200)
|
data/spec/unit/resource_spec.rb
CHANGED
@@ -80,30 +80,27 @@ describe RestClient::Resource do
|
|
80
80
|
end
|
81
81
|
|
82
82
|
it "passes a given block to subresources" do
|
83
|
-
block =
|
83
|
+
block = proc {|r| r}
|
84
84
|
parent = RestClient::Resource.new('http://example.com', &block)
|
85
85
|
parent['posts'].block.should eq block
|
86
86
|
end
|
87
87
|
|
88
88
|
it "the block should be overrideable" do
|
89
|
-
block1 =
|
90
|
-
block2 =
|
89
|
+
block1 = proc {|r| r}
|
90
|
+
block2 = proc {|r| }
|
91
91
|
parent = RestClient::Resource.new('http://example.com', &block1)
|
92
92
|
# parent['posts', &block2].block.should eq block2 # ruby 1.9 syntax
|
93
93
|
parent.send(:[], 'posts', &block2).block.should eq block2
|
94
|
+
parent.send(:[], 'posts', &block2).block.should_not eq block1
|
94
95
|
end
|
95
96
|
|
96
97
|
it "the block should be overrideable in ruby 1.9 syntax" do
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
eval(r19_syntax)
|
104
|
-
else
|
105
|
-
parent.should_not be_nil
|
106
|
-
end
|
98
|
+
block1 = proc {|r| r}
|
99
|
+
block2 = ->(r) {}
|
100
|
+
|
101
|
+
parent = RestClient::Resource.new('http://example.com', &block1)
|
102
|
+
parent['posts', &block2].block.should eq block2
|
103
|
+
parent['posts', &block2].block.should_not eq block1
|
107
104
|
end
|
108
105
|
|
109
106
|
it "prints its url with to_s" do
|
data/spec/unit/response_spec.rb
CHANGED
@@ -35,9 +35,9 @@ describe RestClient::Response do
|
|
35
35
|
response = RestClient::Response.create('abc', net_http_res, {})
|
36
36
|
response.headers[:set_cookie].should eq ["main_page=main_page_no_rewrite; path=/; expires=Tue, 20-Jan-2015 15:03:14 GMT", "remember_me=; path=/; expires=Thu, 01-Jan-1970 00:00:00 GMT", "user=somebody; path=/; expires=Thu, 01-Jan-1970 00:00:00 GMT"]
|
37
37
|
response.cookies.should eq({
|
38
|
-
|
39
|
-
|
40
|
-
|
38
|
+
"main_page" => "main_page_no_rewrite",
|
39
|
+
"remember_me" => "",
|
40
|
+
"user" => "somebody"
|
41
41
|
})
|
42
42
|
end
|
43
43
|
|
@@ -45,9 +45,9 @@ describe RestClient::Response do
|
|
45
45
|
net_http_res = double('net http response', :to_hash => {"etag" => ["\"e1ac1a2df945942ef4cac8116366baad\""], "set-cookie" => ["main_page=main_page_no_rewrite; path=/; expires=Tue, 20-Jan-2015 15:03:14 GMT, remember_me=; path=/; expires=Thu, 01-Jan-1970 00:00:00 GMT, user=somebody; path=/; expires=Thu, 01-Jan-1970 00:00:00 GMT"]})
|
46
46
|
response = RestClient::Response.create('abc', net_http_res, {})
|
47
47
|
response.cookies.should eq({
|
48
|
-
|
49
|
-
|
50
|
-
|
48
|
+
"main_page" => "main_page_no_rewrite",
|
49
|
+
"remember_me" => "",
|
50
|
+
"user" => "somebody"
|
51
51
|
})
|
52
52
|
end
|
53
53
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rest-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.1
|
5
5
|
prerelease:
|
6
6
|
platform: x86-mswin32
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-07-
|
12
|
+
date: 2014-07-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: webmock
|
@@ -102,17 +102,23 @@ dependencies:
|
|
102
102
|
requirement: !ruby/object:Gem::Requirement
|
103
103
|
none: false
|
104
104
|
requirements:
|
105
|
-
- -
|
105
|
+
- - ! '>='
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '1.16'
|
108
|
+
- - <
|
106
109
|
- !ruby/object:Gem::Version
|
107
|
-
version: '
|
110
|
+
version: '3.0'
|
108
111
|
type: :runtime
|
109
112
|
prerelease: false
|
110
113
|
version_requirements: !ruby/object:Gem::Requirement
|
111
114
|
none: false
|
112
115
|
requirements:
|
113
|
-
- -
|
116
|
+
- - ! '>='
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '1.16'
|
119
|
+
- - <
|
114
120
|
- !ruby/object:Gem::Version
|
115
|
-
version: '
|
121
|
+
version: '3.0'
|
116
122
|
- !ruby/object:Gem::Dependency
|
117
123
|
name: netrc
|
118
124
|
requirement: !ruby/object:Gem::Requirement
|
@@ -226,7 +232,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
226
232
|
version: '0'
|
227
233
|
segments:
|
228
234
|
- 0
|
229
|
-
hash: -
|
235
|
+
hash: -2605493040079559984
|
230
236
|
requirements: []
|
231
237
|
rubyforge_project:
|
232
238
|
rubygems_version: 1.8.23.2
|