patron 0.4.17 → 0.4.18

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- patron (0.4.16)
4
+ patron (0.4.18)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -338,9 +338,19 @@ static void set_options_from_request(VALUE self, VALUE request) {
338
338
 
339
339
  action = SYM2ID(rb_iv_get(request, "@action"));
340
340
  if (action == rb_intern("get")) {
341
+ VALUE data = rb_iv_get(request, "@upload_data");
341
342
  VALUE download_file = rb_iv_get(request, "@file_name");
342
343
 
343
344
  curl_easy_setopt(curl, CURLOPT_HTTPGET, 1);
345
+ if (!NIL_P(data)) {
346
+ long len = RSTRING_LEN(data);
347
+ state->upload_buf = StringValuePtr(data);
348
+ curl_easy_setopt(curl, CURLOPT_UPLOAD, 1);
349
+ curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "GET");
350
+ curl_easy_setopt(curl, CURLOPT_READFUNCTION, &session_read_handler);
351
+ curl_easy_setopt(curl, CURLOPT_READDATA, &state->upload_buf);
352
+ curl_easy_setopt(curl, CURLOPT_INFILESIZE, len);
353
+ }
344
354
  if (!NIL_P(download_file)) {
345
355
  state->download_file = open_file(download_file, "w");
346
356
  curl_easy_setopt(curl, CURLOPT_WRITEDATA, state->download_file);
@@ -120,6 +120,8 @@ module Patron
120
120
  # to the +url+ parameter. Any custom headers are merged with the contents
121
121
  # of the +headers+ instance variable. The results are returned in a
122
122
  # Response object.
123
+ # Notice: this method doesn't accept any +data+ argument: if you need to send data with
124
+ # a get request, please, use the #request method.
123
125
  def get(url, headers = {})
124
126
  request(:get, url, headers)
125
127
  end
@@ -1,3 +1,3 @@
1
1
  module Patron
2
- VERSION = "0.4.17"
2
+ VERSION = "0.4.18"
3
3
  end
@@ -130,6 +130,14 @@ describe Patron::Session do
130
130
  body.header['destination'].first.should == "/test2"
131
131
  end
132
132
 
133
+ it "should upload data with :get" do
134
+ data = "upload data"
135
+ response = @session.request(:get, "/test", {}, :data => data)
136
+ body = YAML::load(response.body)
137
+ body.request_method.should == "GET"
138
+ body.header['content-length'].should == [data.size.to_s]
139
+ end
140
+
133
141
  it "should upload data with :put" do
134
142
  data = "upload data"
135
143
  response = @session.put("/test", data)
@@ -267,14 +275,14 @@ describe Patron::Session do
267
275
 
268
276
  body.request_method.should == "GET"
269
277
  end
270
-
278
+
271
279
  it "should serialize query params and append them to the url" do
272
280
  response = @session.request(:get, "/test", {}, :query => {:foo => "bar"})
273
281
  request = YAML::load(response.body)
274
282
  request.parse
275
283
  (request.path + '?' + request.query_string).should == "/test?foo=bar"
276
284
  end
277
-
285
+
278
286
  it "should merge parameters in the :query option with pre-existing query parameters" do
279
287
  response = @session.request(:get, "/test?foo=bar", {}, :query => {:baz => "quux"})
280
288
  request = YAML::load(response.body)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: patron
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.17
4
+ version: 0.4.18
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-21 00:00:00.000000000 Z
12
+ date: 2012-03-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
16
- requirement: &70199940489140 !ruby/object:Gem::Requirement
16
+ requirement: &70336820705120 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.0.0
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70199940489140
24
+ version_requirements: *70336820705120
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake-compiler
27
- requirement: &70199940488660 !ruby/object:Gem::Requirement
27
+ requirement: &70336820704660 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.7.5
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70199940488660
35
+ version_requirements: *70336820704660
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &70199940488200 !ruby/object:Gem::Requirement
38
+ requirement: &70336820704200 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 2.3.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70199940488200
46
+ version_requirements: *70336820704200
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rcov
49
- requirement: &70199940487740 !ruby/object:Gem::Requirement
49
+ requirement: &70336820703740 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: 0.9.9
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70199940487740
57
+ version_requirements: *70336820703740
58
58
  description: Ruby HTTP client library based on libcurl
59
59
  email:
60
60
  - phil.toland@gmail.com