patron 0.4.4 → 0.4.5

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.
data/Rakefile CHANGED
@@ -61,6 +61,7 @@ Jeweler::Tasks.new do |s|
61
61
  s.require_paths << 'ext'
62
62
 
63
63
  s.files = FileList['README.txt',
64
+ 'VERSION.yml',
64
65
  'LICENSE',
65
66
  'Rakefile',
66
67
  'lib/**/*',
@@ -0,0 +1,5 @@
1
+ ---
2
+ :major: 0
3
+ :minor: 4
4
+ :patch: 5
5
+ :build:
@@ -21,6 +21,11 @@
21
21
  ## THE SOFTWARE.
22
22
  ##
23
23
  ## -------------------------------------------------------------------
24
+
25
+ if RUBY_PLATFORM =~ /darwin10\.0/
26
+ ENV['ARCHFLAGS'] = '-arch x86_64'
27
+ end
28
+
24
29
  require 'mkmf'
25
30
  require 'rbconfig'
26
31
 
@@ -70,7 +70,7 @@ static size_t session_read_handler(char* stream, size_t size, size_t nmemb, char
70
70
 
71
71
  return result;
72
72
  }
73
-
73
+
74
74
  //------------------------------------------------------------------------------
75
75
  // Object allocation
76
76
  //
@@ -256,7 +256,7 @@ static void set_options_from_request(VALUE self, VALUE request) {
256
256
 
257
257
  timeout = rb_iv_get(request, "@connect_timeout");
258
258
  if (!NIL_P(timeout)) {
259
- curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT_MS, FIX2INT(timeout));
259
+ curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, FIX2INT(timeout));
260
260
  }
261
261
 
262
262
  VALUE redirects = rb_iv_get(request, "@max_redirects");
@@ -342,11 +342,12 @@ static VALUE perform_request(VALUE self) {
342
342
  curl_easy_setopt(curl, CURLOPT_WRITEDATA, body_buffer);
343
343
  }
344
344
 
345
- #ifdef HAVE_TBR
345
+ #if defined(HAVE_TBR) && defined(USE_TBR)
346
346
  CURLcode ret = rb_thread_blocking_region(curl_easy_perform, curl, RUBY_UBF_IO, 0);
347
347
  #else
348
348
  CURLcode ret = curl_easy_perform(curl);
349
349
  #endif
350
+
350
351
  if (CURLE_OK == ret) {
351
352
  VALUE response = create_response(curl);
352
353
  if (!NIL_P(body_buffer)) {
@@ -423,12 +424,12 @@ void Init_session_ext() {
423
424
  ePartialFileError = rb_const_get(mPatron, rb_intern("PartialFileError"));
424
425
  eTimeoutError = rb_const_get(mPatron, rb_intern("TimeoutError"));
425
426
  eTooManyRedirects = rb_const_get(mPatron, rb_intern("TooManyRedirects"));
426
-
427
+
427
428
 
428
429
  rb_define_module_function(mPatron, "libcurl_version", libcurl_version, 0);
429
430
 
430
431
  cSession = rb_define_class_under(mPatron, "Session", rb_cObject);
431
- cRequest = rb_define_class_under(mPatron, "Request", rb_cObject);
432
+ cRequest = rb_define_class_under(mPatron, "Request", rb_cObject);
432
433
  rb_define_alloc_func(cSession, session_alloc);
433
434
 
434
435
  rb_define_method(cSession, "ext_initialize", session_ext_initialize, 0);
@@ -437,8 +438,8 @@ void Init_session_ext() {
437
438
  rb_define_method(cSession, "handle_request", session_handle_request, 1);
438
439
  rb_define_method(cSession, "enable_cookie_session", enable_cookie_session, 1);
439
440
 
440
- rb_define_const(cRequest, "AuthBasic", CURLAUTH_BASIC);
441
- rb_define_const(cRequest, "AuthDigest", CURLAUTH_DIGEST);
442
- rb_define_const(cRequest, "AuthAny", CURLAUTH_ANY);
443
-
441
+ rb_define_const(cRequest, "AuthBasic", CURLAUTH_BASIC);
442
+ rb_define_const(cRequest, "AuthDigest", CURLAUTH_DIGEST);
443
+ rb_define_const(cRequest, "AuthAny", CURLAUTH_ANY);
444
+
444
445
  }
@@ -49,7 +49,11 @@ module Patron
49
49
  else
50
50
  parts = header.split(':', 2)
51
51
  parts[1].strip! unless parts[1].nil?
52
- @headers[parts[0]] = parts[1]
52
+ if @headers.has_key?(parts[0])
53
+ @headers[parts[0]] << ",#{parts[1]}"
54
+ else
55
+ @headers[parts[0]] = parts[1]
56
+ end
53
57
  end
54
58
  end
55
59
  end
@@ -34,14 +34,14 @@ module Patron
34
34
  # server. This is the primary API for Patron.
35
35
  class Session
36
36
 
37
- # HTTP connection timeout in milliseconds. Defaults to 1 second (1000 ms).
37
+ # HTTP connection timeout in seconds. Defaults to 1 second.
38
38
  attr_accessor :connect_timeout
39
39
 
40
40
  # HTTP transaction timeout in seconds. Defaults to 5 seconds.
41
41
  attr_accessor :timeout
42
42
 
43
43
  # Maximum number of times to follow redirects.
44
- # Set to 0 to disable and -1 to follow all redirects (the default).
44
+ # Set to 0 to disable and -1 to follow all redirects. Defaults to 5.
45
45
  attr_accessor :max_redirects
46
46
 
47
47
  # Prepended to the URL in all requests.
@@ -70,8 +70,8 @@ module Patron
70
70
  ext_initialize
71
71
  @headers = {}
72
72
  @timeout = 5
73
- @connect_timeout = 1000
74
- @max_redirects = -1
73
+ @connect_timeout = 1
74
+ @max_redirects = 5
75
75
  @auth_type = :basic
76
76
  end
77
77
 
@@ -37,4 +37,9 @@ describe Patron::Response do
37
37
  # All digits, no spaces
38
38
  response.headers['Content-Length'].should match(/^\d+$/)
39
39
  end
40
+
41
+ it "should combine header values sent in different fields with same name" do
42
+ response = @session.get("/repetitiveheader")
43
+ response.headers['Set-Cookie'].should == "a=1,b=2"
44
+ end
40
45
  end
@@ -207,7 +207,19 @@ describe Patron::Session do
207
207
  it "should raise exception if cookie store is not writable or readable" do
208
208
  lambda { @session.handle_cookies("/trash/clash/foo") }.should raise_error(ArgumentError)
209
209
  end
210
-
210
+
211
+ it "should work with multiple threads" do
212
+ threads = []
213
+ 3.times do
214
+ threads << Thread.new do
215
+ session = Patron::Session.new
216
+ session.base_url = "http://localhost:9001"
217
+ session.post_file("/test", "VERSION.yml")
218
+ end
219
+ end
220
+ threads.each {|t| t.join }
221
+ end
222
+
211
223
  def encode_authz(user, passwd)
212
224
  "Basic " + Base64.encode64("#{user}:#{passwd}").strip
213
225
  end
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.4
4
+ version: 0.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Phillip Toland
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-04 00:00:00 -05:00
12
+ date: 2010-01-28 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -19,12 +19,14 @@ executables: []
19
19
 
20
20
  extensions:
21
21
  - ext/patron/extconf.rb
22
+ - ext/patron/extconf.rb
22
23
  extra_rdoc_files:
23
24
  - README.txt
24
25
  files:
25
26
  - LICENSE
26
27
  - README.txt
27
28
  - Rakefile
29
+ - VERSION.yml
28
30
  - ext/patron/extconf.rb
29
31
  - ext/patron/session_ext.c
30
32
  - lib/patron.rb
@@ -56,6 +58,7 @@ rdoc_options:
56
58
  require_paths:
57
59
  - lib
58
60
  - ext
61
+ - ext
59
62
  required_ruby_version: !ruby/object:Gem::Requirement
60
63
  requirements:
61
64
  - - ">="