curb 0.9.5 → 0.9.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b3b322d2ebc81428defb20ae37afc57287d05cc7
4
- data.tar.gz: e2b87dc289c5c0268b927d78afd5d1ccdd3b3e73
3
+ metadata.gz: 53aeed05cc43efb7e736097fd212e43a8b25e21b
4
+ data.tar.gz: 129c6741252ba30006df855fb7543eba7e706fca
5
5
  SHA512:
6
- metadata.gz: 56080e5ef72c525be4b575c74b3832aa62d1074923237922f1568d7c3027e2eb654770a5a6187e0cc1f359c5228cae0aa7ea02cb95cafe6218d848595cb1a1f9
7
- data.tar.gz: c9625176e56a5bb0b3716b1d6c8604f3bcfe406933a78a1cb371e20b9b4c4072477c1cebb52772ce793ab94adc3cbf8b9cba8264df0a3bf2498fdabb23885852
6
+ metadata.gz: e2f6065c80853bdc3d17d69316e202b7f7f73d5ab4925171fa50847e370978b67f4419144559305beb002a7e91dc5cf6b359b1d643237cb17699c37ba07d936f
7
+ data.tar.gz: b76fd1724733c9566e4150c4467370ca63a40838f59e8b6ab1412d8b893eca1ebfe12cca6bb8ac59f607292498daa4e97d06fd9239ac7d651b5441b4e2f2abfa
data/ext/curb.h CHANGED
@@ -20,10 +20,10 @@
20
20
  #include "curb_macros.h"
21
21
 
22
22
  // These should be managed from the Rake 'release' task.
23
- #define CURB_VERSION "0.9.5"
24
- #define CURB_VER_NUM 905
23
+ #define CURB_VERSION "0.9.6"
24
+ #define CURB_VER_NUM 906
25
25
  #define CURB_VER_MAJ 0
26
- #define CURB_VER_MIN 5
26
+ #define CURB_VER_MIN 6
27
27
  #define CURB_VER_MIC 0
28
28
  #define CURB_VER_PATCH 0
29
29
 
@@ -436,10 +436,6 @@ static void rb_curl_mutli_handle_complete(VALUE self, CURL *easy_handle, int res
436
436
  //rb_funcall( rb_easy_get("failure_proc"), idCall, 2, easy, rb_curl_easy_error(result) );
437
437
  }
438
438
 
439
- if (val == Qfalse) {
440
- rb_warn("uncaught exception from callback");
441
- }
442
-
443
439
  }
444
440
 
445
441
  static void rb_curl_multi_read_info(VALUE self, CURLM *multi_handle) {
@@ -6,7 +6,7 @@ require 'cgi'
6
6
 
7
7
  # expose shortcut methods
8
8
  module Curl
9
-
9
+
10
10
  def self.http(verb, url, post_body=nil, put_data=nil, &block)
11
11
  handle = Thread.current[:curb_curl] ||= Curl::Easy.new
12
12
  handle.reset
@@ -48,7 +48,7 @@ module Curl
48
48
 
49
49
  def self.urlalize(url, params={})
50
50
  uri = URI(url)
51
- params_query = params.map {|k,v| "#{URI.escape(k.to_s)}=#{URI.escape(v.to_s)}" }.join("&")
51
+ params_query = URI.encode_www_form(params || {})
52
52
  # both uri.query and params_query not blank
53
53
  if !(uri.query.nil? || uri.query.empty?) && !params_query.empty?
54
54
  uri.query = "#{uri.query}&#{params_query}"
@@ -19,8 +19,8 @@ module Curl
19
19
  # easy.status => String
20
20
  #
21
21
  def status
22
- # Matches the last HTTP Status - following the HTTP protocol specification 'Status-Line = HTTP-Version SP Status-Code SP Reason-Phrase CRLF'
23
- statuses = self.header_str.scan(/HTTP\/\d\.\d\s(\d+\s.*)\r\n/).map{ |match| match[0] }
22
+ # Matches the last HTTP Status - following the HTTP protocol specification 'Status-Line = HTTP-Version SP Status-Code SP (Opt:)Reason-Phrase CRLF'
23
+ statuses = self.header_str.scan(/HTTP\/\d(\.\d)?\s(\d+\s.*)\r\n/).map{ |match| match[1] }
24
24
  statuses.last.strip if statuses.length > 0
25
25
  end
26
26
 
@@ -6,7 +6,7 @@ module Curl
6
6
  # Curl::Multi.get(['url1','url2','url3','url4','url5'], :follow_location => true) do|easy|
7
7
  # easy
8
8
  # end
9
- #
9
+ #
10
10
  # Blocking call to fetch multiple url's in parallel.
11
11
  def get(urls, easy_options={}, multi_options={}, &blk)
12
12
  url_confs = []
@@ -25,10 +25,10 @@ module Curl
25
25
  # {:pipeline => Curl::CURLPIPE_HTTP1}) do|easy|
26
26
  # easy_handle_on_request_complete
27
27
  # end
28
- #
28
+ #
29
29
  # Blocking call to POST multiple form's in parallel.
30
- #
31
- # urls_with_config: is a hash of url's pointing to the postfields to send
30
+ #
31
+ # urls_with_config: is a hash of url's pointing to the postfields to send
32
32
  # easy_options: are a set of common options to set on all easy handles
33
33
  # multi_options: options to set on the Curl::Multi handle
34
34
  #
@@ -49,10 +49,10 @@ module Curl
49
49
  # {:pipeline => Curl::CURLPIPE_HTTP1}) do|easy|
50
50
  # easy_handle_on_request_complete
51
51
  # end
52
- #
52
+ #
53
53
  # Blocking call to POST multiple form's in parallel.
54
- #
55
- # urls_with_config: is a hash of url's pointing to the postfields to send
54
+ #
55
+ # urls_with_config: is a hash of url's pointing to the postfields to send
56
56
  # easy_options: are a set of common options to set on all easy handles
57
57
  # multi_options: options to set on the Curl::Multi handle
58
58
  #
@@ -79,7 +79,7 @@ module Curl
79
79
  # Blocking call to issue multiple HTTP requests with varying verb's.
80
80
  #
81
81
  # urls_with_config: is a hash of url's pointing to the easy handle options as well as the special option :method, that can by one of [:get, :post, :put, :delete, :head], when no verb is provided e.g. :method => nil -> GET is used
82
- # multi_options: options for the multi handle
82
+ # multi_options: options for the multi handle
83
83
  # blk: a callback, that yeilds when a handle is completed
84
84
  #
85
85
  def http(urls_with_config, multi_options={}, &blk)
@@ -128,7 +128,7 @@ module Curl
128
128
 
129
129
  # headers is a special key
130
130
  headers.each {|k,v| easy.headers[k] = v } if headers
131
-
131
+
132
132
  #
133
133
  # use the remaining options as specific configuration to the easy handle
134
134
  # bad options should raise an undefined method error
@@ -175,7 +175,7 @@ module Curl
175
175
  # Curl::Multi.download(['http://example.com/p/a/t/h/file1.txt','http://example.com/p/a/t/h/file2.txt']){|c|}
176
176
  #
177
177
  # will create 2 new files file1.txt and file2.txt
178
- #
178
+ #
179
179
  # 2 files will be opened, and remain open until the call completes
180
180
  #
181
181
  # when using the :post or :put method, urls should be a hash, including the individual post fields per post
@@ -18,7 +18,7 @@ rescue LoadError
18
18
  end
19
19
  require 'fileutils'
20
20
 
21
- $TEST_URL = "file://#{'/' if RUBY_DESCRIPTION =~ /mswin|msys|mingw|cygwin|bccwin|wince|emc/}#{URI.escape(File.expand_path(__FILE__).tr('\\','/'))}"
21
+ $TEST_URL = "file://#{'/' if RUBY_DESCRIPTION =~ /mswin|msys|mingw|cygwin|bccwin|wince|emc/}#{File.expand_path(__FILE__).tr('\\','/')}"
22
22
 
23
23
  require 'thread'
24
24
  require 'webrick'
@@ -30,19 +30,22 @@ require 'webrick'
30
30
  TEST_SINGLE_THREADED=false
31
31
 
32
32
  # keep webrick quiet
33
- class ::WEBrick::HTTPServer
33
+ ::WEBrick::HTTPServer.send(:remove_method,:access_log) if ::WEBrick::HTTPServer.instance_methods.include?(:access_log)
34
+ ::WEBrick::BasicLog.send(:remove_method,:log) if ::WEBrick::BasicLog.instance_methods.include?(:log)
35
+
36
+ ::WEBrick::HTTPServer.class_eval do
34
37
  def access_log(config, req, res)
35
38
  # nop
36
39
  end
37
40
  end
38
- class ::WEBrick::BasicLog
41
+ ::WEBrick::BasicLog.class_eval do
39
42
  def log(level, data)
40
43
  # nop
41
44
  end
42
45
  end
43
46
 
44
47
  #
45
- # Simple test server to record number of times a request is sent/recieved of a specific
48
+ # Simple test server to record number of times a request is sent/recieved of a specific
46
49
  # request type, e.g. GET,POST,PUT,DELETE
47
50
  #
48
51
  class TestServlet < WEBrick::HTTPServlet::AbstractServlet
@@ -147,7 +150,7 @@ module TestServerMethods
147
150
  rd.close
148
151
  rd = nil
149
152
 
150
- # start up a webrick server for testing delete
153
+ # start up a webrick server for testing delete
151
154
  server = WEBrick::HTTPServer.new :Port => port, :DocumentRoot => File.expand_path(File.dirname(__FILE__))
152
155
 
153
156
  server.mount(servlet.path, servlet)
@@ -163,7 +166,7 @@ module TestServerMethods
163
166
  rd.read
164
167
  rd.close
165
168
  else
166
- # start up a webrick server for testing delete
169
+ # start up a webrick server for testing delete
167
170
  @server = WEBrick::HTTPServer.new :Port => port, :DocumentRoot => File.expand_path(File.dirname(__FILE__))
168
171
 
169
172
  @server.mount(servlet.path, servlet)
@@ -31,7 +31,7 @@ class TestCurl < Test::Unit::TestCase
31
31
  assert_equal "OPTIONSfoo=bar", curl.body_str
32
32
  end
33
33
 
34
- include TestServerMethods
34
+ include TestServerMethods
35
35
 
36
36
  def setup
37
37
  server_setup
@@ -10,6 +10,16 @@ class TestCurbCurlEasy < Test::Unit::TestCase
10
10
  Curl.reset
11
11
  end
12
12
 
13
+ def test_exception
14
+ begin
15
+ Curl.get('NOT_FOUND_URL')
16
+ rescue
17
+ assert true
18
+ rescue Exception
19
+ assert false, "We should raise StandardError"
20
+ end
21
+ end
22
+
13
23
  def test_threads
14
24
  t = []
15
25
  5.times do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: curb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.5
4
+ version: 0.9.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ross Bamford