patron 0.4.7 → 0.4.8
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +0 -5
- data/VERSION.yml +1 -1
- data/ext/patron/session_ext.c +4 -6
- data/lib/patron/request.rb +25 -26
- data/lib/patron/session.rb +2 -3
- metadata +4 -4
data/Rakefile
CHANGED
data/VERSION.yml
CHANGED
data/ext/patron/session_ext.c
CHANGED
@@ -273,7 +273,7 @@ static void set_options_from_request(VALUE self, VALUE request) {
|
|
273
273
|
|
274
274
|
VALUE credentials = rb_funcall(request, rb_intern("credentials"), 0);
|
275
275
|
if (!NIL_P(credentials)) {
|
276
|
-
curl_easy_setopt(curl, CURLOPT_HTTPAUTH, rb_iv_get(request, "@auth_type"));
|
276
|
+
curl_easy_setopt(curl, CURLOPT_HTTPAUTH, FIX2INT(rb_iv_get(request, "@auth_type")));
|
277
277
|
curl_easy_setopt(curl, CURLOPT_USERPWD, StringValuePtr(credentials));
|
278
278
|
}
|
279
279
|
|
@@ -342,11 +342,11 @@ static VALUE perform_request(VALUE self) {
|
|
342
342
|
curl_easy_setopt(curl, CURLOPT_WRITEDATA, body_buffer);
|
343
343
|
}
|
344
344
|
|
345
|
-
|
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
351
|
if (CURLE_OK == ret) {
|
352
352
|
VALUE response = create_response(curl);
|
@@ -425,7 +425,6 @@ void Init_session_ext() {
|
|
425
425
|
eTimeoutError = rb_const_get(mPatron, rb_intern("TimeoutError"));
|
426
426
|
eTooManyRedirects = rb_const_get(mPatron, rb_intern("TooManyRedirects"));
|
427
427
|
|
428
|
-
|
429
428
|
rb_define_module_function(mPatron, "libcurl_version", libcurl_version, 0);
|
430
429
|
|
431
430
|
cSession = rb_define_class_under(mPatron, "Session", rb_cObject);
|
@@ -441,5 +440,4 @@ void Init_session_ext() {
|
|
441
440
|
rb_define_const(cRequest, "AuthBasic", INT2FIX(CURLAUTH_BASIC));
|
442
441
|
rb_define_const(cRequest, "AuthDigest", INT2FIX(CURLAUTH_DIGEST));
|
443
442
|
rb_define_const(cRequest, "AuthAny", INT2FIX(CURLAUTH_ANY));
|
444
|
-
|
445
443
|
}
|
data/lib/patron/request.rb
CHANGED
@@ -43,28 +43,28 @@ module Patron
|
|
43
43
|
attr_accessor :url, :username, :password, :file_name, :proxy, :auth_type, :insecure
|
44
44
|
attr_reader :action, :timeout, :connect_timeout, :max_redirects, :headers
|
45
45
|
attr_reader :auth_type
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
end
|
46
|
+
|
47
|
+
# Set the type of authentication to use for this request.
|
48
|
+
#
|
49
|
+
# @param [String, Symbol] type - The type of authentication to use for this request, can be one of
|
50
|
+
# :basic, :digest, or :any
|
51
|
+
#
|
52
|
+
# @example
|
53
|
+
# sess.username = "foo"
|
54
|
+
# sess.password = "sekrit"
|
55
|
+
# sess.auth_type = :digest
|
56
|
+
def auth_type=(type=:basic)
|
57
|
+
@auth_type = case type
|
58
|
+
when :basic, "basic"
|
59
|
+
Request::AuthBasic
|
60
|
+
when :digest, "digest"
|
61
|
+
Request::AuthDigest
|
62
|
+
when :any, "any"
|
63
|
+
Request::AuthAny
|
64
|
+
else
|
65
|
+
raise "#{type.inspect} is an unknown authentication type"
|
67
66
|
end
|
67
|
+
end
|
68
68
|
|
69
69
|
def upload_data=(data)
|
70
70
|
@upload_data = case data
|
@@ -74,7 +74,7 @@ module Patron
|
|
74
74
|
data
|
75
75
|
end
|
76
76
|
end
|
77
|
-
|
77
|
+
|
78
78
|
def upload_data
|
79
79
|
@upload_data
|
80
80
|
end
|
@@ -128,12 +128,12 @@ module Patron
|
|
128
128
|
"#{username}:#{password}"
|
129
129
|
end
|
130
130
|
|
131
|
-
|
132
|
-
|
131
|
+
private
|
132
|
+
|
133
133
|
# serialize hash for Rails-style params
|
134
134
|
def hash_to_string(hash)
|
135
135
|
pairs = []
|
136
|
-
recursive = Proc.new do |h, prefix|
|
136
|
+
recursive = Proc.new do |h, prefix|
|
137
137
|
h.each_pair do |k,v|
|
138
138
|
key = prefix == '' ? k : "#{prefix}[#{k}]"
|
139
139
|
v.is_a?(Hash) ? recursive.call(v, key) : pairs << "#{key}=#{v}"
|
@@ -142,6 +142,5 @@ module Patron
|
|
142
142
|
recursive.call(hash, '')
|
143
143
|
return pairs.join('&')
|
144
144
|
end
|
145
|
-
|
146
145
|
end
|
147
146
|
end
|
data/lib/patron/session.rb
CHANGED
@@ -55,7 +55,7 @@ module Patron
|
|
55
55
|
|
56
56
|
# Standard set of headers that are used in all requests.
|
57
57
|
attr_reader :headers
|
58
|
-
|
58
|
+
|
59
59
|
# Set the authentication type for the request.
|
60
60
|
# @see Patron::Request#auth_type
|
61
61
|
attr_accessor :auth_type
|
@@ -141,7 +141,7 @@ module Patron
|
|
141
141
|
# Uploads the contents of a file to the specified +url+ using HTTP POST.
|
142
142
|
def post_file(url, filename, headers = {})
|
143
143
|
request(:post, url, headers, :file => filename)
|
144
|
-
end
|
144
|
+
end
|
145
145
|
|
146
146
|
###################################################################
|
147
147
|
### WebDAV methods
|
@@ -181,6 +181,5 @@ module Patron
|
|
181
181
|
|
182
182
|
handle_request(req)
|
183
183
|
end
|
184
|
-
|
185
184
|
end
|
186
185
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: patron
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 0.4.
|
9
|
+
- 8
|
10
|
+
version: 0.4.8
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Phillip Toland
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-09-
|
18
|
+
date: 2010-09-02 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|