rest-client 1.6.5 → 1.6.6
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/README.rdoc +9 -0
- data/VERSION +1 -1
- data/history.md +6 -0
- data/lib/restclient/net_http_ext.rb +42 -8
- data/lib/restclient/payload.rb +1 -1
- data/lib/restclient/request.rb +2 -0
- data/spec/payload_spec.rb +10 -0
- data/spec/request2_spec.rb +13 -0
- metadata +7 -7
data/README.rdoc
CHANGED
@@ -217,6 +217,15 @@ use whatever proxy the system is configured to use:
|
|
217
217
|
|
218
218
|
RestClient.proxy = ENV['http_proxy']
|
219
219
|
|
220
|
+
== Query parameters
|
221
|
+
|
222
|
+
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:
|
225
|
+
|
226
|
+
RestClient.get 'http://example.com/resource', :params => {:foo => 'bar', :baz => 'qux'}
|
227
|
+
# will GET http://example.com/resource?foo=bar&baz=qux
|
228
|
+
|
220
229
|
== Cookies
|
221
230
|
|
222
231
|
Request and Response objects know about HTTP cookies, and will automatically
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.6.
|
1
|
+
1.6.6
|
data/history.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
# 1.6.6
|
2
|
+
|
3
|
+
- 1.6.6 was yanked
|
4
|
+
|
1
5
|
# 1.6.5
|
2
6
|
|
3
7
|
- RFC6265 requires single SP after ';' for separating parameters pairs in the 'Cookie:' header (patch provided by Hiroshi Nakamura)
|
@@ -8,6 +12,8 @@
|
|
8
12
|
# 1.6.4
|
9
13
|
|
10
14
|
- fix restclient script compatibility with 1.9.2
|
15
|
+
- fix unlinking temp file (patch provided by Evan Smith)
|
16
|
+
- monkeypatching ruby for http patch method (patch provided by Syl Turner)
|
11
17
|
|
12
18
|
# 1.6.3
|
13
19
|
|
@@ -1,12 +1,46 @@
|
|
1
|
-
#
|
2
|
-
# Replace the request method in Net::HTTP to sniff the body type
|
3
|
-
# and set the stream if appropriate
|
4
|
-
#
|
5
|
-
# Taken from:
|
6
|
-
# http://www.missiondata.com/blog/ruby/29/streaming-data-to-s3-with-ruby/
|
7
|
-
|
8
1
|
module Net
|
9
|
-
class HTTP
|
2
|
+
class HTTP
|
3
|
+
|
4
|
+
# Adding the patch method if it doesn't exist (rest-client issue: https://github.com/archiloque/rest-client/issues/79)
|
5
|
+
if !defined?(Net::HTTP::Patch)
|
6
|
+
# Code taken from this commit: https://github.com/ruby/ruby/commit/ab70e53ac3b5102d4ecbe8f38d4f76afad29d37d#lib/net/http.rb
|
7
|
+
class Protocol
|
8
|
+
# Sends a PATCH request to the +path+ and gets a response,
|
9
|
+
# as an HTTPResponse object.
|
10
|
+
def patch(path, data, initheader = nil, dest = nil, &block) # :yield: +body_segment+
|
11
|
+
send_entity(path, data, initheader, dest, Patch, &block)
|
12
|
+
end
|
13
|
+
|
14
|
+
# Executes a request which uses a representation
|
15
|
+
# and returns its body.
|
16
|
+
def send_entity(path, data, initheader, dest, type, &block)
|
17
|
+
res = nil
|
18
|
+
request(type.new(path, initheader), data) {|r|
|
19
|
+
r.read_body dest, &block
|
20
|
+
res = r
|
21
|
+
}
|
22
|
+
unless @newimpl
|
23
|
+
res.value
|
24
|
+
return res, res.body
|
25
|
+
end
|
26
|
+
res
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
class Patch < HTTPRequest
|
31
|
+
METHOD = 'PATCH'
|
32
|
+
REQUEST_HAS_BODY = true
|
33
|
+
RESPONSE_HAS_BODY = true
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
#
|
38
|
+
# Replace the request method in Net::HTTP to sniff the body type
|
39
|
+
# and set the stream if appropriate
|
40
|
+
#
|
41
|
+
# Taken from:
|
42
|
+
# http://www.missiondata.com/blog/ruby/29/streaming-data-to-s3-with-ruby/
|
43
|
+
|
10
44
|
alias __request__ request
|
11
45
|
|
12
46
|
def request(req, body=nil, &block)
|
data/lib/restclient/payload.rb
CHANGED
data/lib/restclient/request.rb
CHANGED
@@ -62,6 +62,8 @@ module RestClient
|
|
62
62
|
def execute & block
|
63
63
|
uri = parse_url_with_auth(url)
|
64
64
|
transmit uri, net_http_request_class(method).new(uri.request_uri, processed_headers), payload, & block
|
65
|
+
ensure
|
66
|
+
payload.close if payload
|
65
67
|
end
|
66
68
|
|
67
69
|
# Extract the query parameters and append them to the url
|
data/spec/payload_spec.rb
CHANGED
@@ -54,6 +54,11 @@ describe RestClient::Payload do
|
|
54
54
|
RestClient::Payload::UrlEncoded.new({:foo => ['bar', 'baz']}).to_s.
|
55
55
|
should == "foo[]=bar&foo[]=baz"
|
56
56
|
end
|
57
|
+
|
58
|
+
it 'should not close if stream already closed' do
|
59
|
+
p = RestClient::Payload::UrlEncoded.new({'foo ' => 'bar'})
|
60
|
+
3.times {p.close}
|
61
|
+
end
|
57
62
|
|
58
63
|
end
|
59
64
|
|
@@ -63,6 +68,11 @@ describe RestClient::Payload do
|
|
63
68
|
m.stub!(:boundary).and_return(123)
|
64
69
|
m.headers['Content-Type'].should == 'multipart/form-data; boundary=123'
|
65
70
|
end
|
71
|
+
|
72
|
+
it 'should not error on close if stream already closed' do
|
73
|
+
m = RestClient::Payload::Multipart.new(:file => File.new(File.join(File.dirname(File.expand_path(__FILE__)), 'master_shake.jpg')))
|
74
|
+
3.times {m.close}
|
75
|
+
end
|
66
76
|
|
67
77
|
it "should form properly separated multipart data" do
|
68
78
|
m = RestClient::Payload::Multipart.new([[:bar, "baz"], [:foo, "bar"]])
|
data/spec/request2_spec.rb
CHANGED
@@ -23,5 +23,18 @@ describe RestClient::Request do
|
|
23
23
|
response_value.should == "foo"
|
24
24
|
end
|
25
25
|
|
26
|
+
it 'closes payload if not nil' do
|
27
|
+
test_file = File.new(File.join( File.dirname(File.expand_path(__FILE__)), 'master_shake.jpg'))
|
28
|
+
initial_count = tmp_count
|
29
|
+
|
30
|
+
stub_request(:post, 'http://some/resource').with(:headers => {'Accept'=>'*/*; q=0.5, application/xml', 'Accept-Encoding'=>'gzip, deflate'}).to_return(:body => 'foo', :status => 200)
|
31
|
+
RestClient::Request.execute(:url => 'http://some/resource', :method => :post, :payload => {:file => test_file})
|
32
|
+
|
33
|
+
tmp_count.should == initial_count
|
34
|
+
end
|
35
|
+
|
26
36
|
end
|
27
37
|
|
38
|
+
def tmp_count
|
39
|
+
Dir.glob(Dir::tmpdir + "/*").size
|
40
|
+
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.6.
|
4
|
+
version: 1.6.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -14,7 +14,7 @@ date: 2011-08-22 00:00:00.000000000Z
|
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: mime-types
|
17
|
-
requirement: &
|
17
|
+
requirement: &2156542220 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: '1.16'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *2156542220
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: webmock
|
28
|
-
requirement: &
|
28
|
+
requirement: &2156541580 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: 0.9.1
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *2156541580
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: rspec
|
39
|
-
requirement: &
|
39
|
+
requirement: &2156541040 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ! '>='
|
@@ -44,7 +44,7 @@ dependencies:
|
|
44
44
|
version: '0'
|
45
45
|
type: :development
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *2156541040
|
48
48
|
description: ! 'A simple HTTP and REST client for Ruby, inspired by the Sinatra microframework
|
49
49
|
style of specifying actions: get, put, post, delete.'
|
50
50
|
email: rest.client@librelist.com
|