excon 0.49.0 → 0.88.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +5 -5
  2. data/CONTRIBUTORS.md +33 -3
  3. data/LICENSE.md +1 -1
  4. data/README.md +77 -7
  5. data/data/cacert.pem +1279 -1940
  6. data/excon.gemspec +32 -170
  7. data/lib/excon/connection.rb +257 -154
  8. data/lib/excon/constants.rb +44 -16
  9. data/lib/excon/error.rb +229 -0
  10. data/lib/excon/extensions/uri.rb +1 -0
  11. data/lib/excon/headers.rb +5 -3
  12. data/lib/excon/instrumentors/logging_instrumentor.rb +48 -0
  13. data/lib/excon/instrumentors/standard_instrumentor.rb +21 -0
  14. data/lib/excon/middlewares/base.rb +7 -0
  15. data/lib/excon/middlewares/capture_cookies.rb +2 -1
  16. data/lib/excon/middlewares/decompress.rb +3 -2
  17. data/lib/excon/middlewares/escape_path.rb +1 -0
  18. data/lib/excon/middlewares/expects.rb +8 -1
  19. data/lib/excon/middlewares/idempotent.rb +27 -3
  20. data/lib/excon/middlewares/instrumentor.rb +9 -0
  21. data/lib/excon/middlewares/mock.rb +14 -4
  22. data/lib/excon/middlewares/redirect_follower.rb +28 -4
  23. data/lib/excon/middlewares/response_parser.rb +4 -0
  24. data/lib/excon/pretty_printer.rb +2 -8
  25. data/lib/excon/response.rb +16 -12
  26. data/lib/excon/socket.rb +56 -36
  27. data/lib/excon/ssl_socket.rb +70 -25
  28. data/lib/excon/test/plugin/server/exec.rb +26 -0
  29. data/lib/excon/test/plugin/server/puma.rb +23 -0
  30. data/lib/excon/test/plugin/server/unicorn.rb +38 -0
  31. data/lib/excon/test/plugin/server/webrick.rb +26 -0
  32. data/lib/excon/test/server.rb +106 -0
  33. data/lib/excon/unix_socket.rb +2 -0
  34. data/lib/excon/utils.rb +65 -10
  35. data/lib/excon/version.rb +4 -0
  36. data/lib/excon.rb +35 -20
  37. metadata +69 -87
  38. data/Gemfile +0 -19
  39. data/Gemfile.lock +0 -285
  40. data/Rakefile +0 -144
  41. data/benchmarks/class_vs_lambda.rb +0 -50
  42. data/benchmarks/concat_vs_insert.rb +0 -21
  43. data/benchmarks/concat_vs_interpolate.rb +0 -21
  44. data/benchmarks/cr_lf.rb +0 -21
  45. data/benchmarks/downcase-eq-eq_vs_casecmp.rb +0 -169
  46. data/benchmarks/excon.rb +0 -69
  47. data/benchmarks/excon_vs.rb +0 -165
  48. data/benchmarks/for_vs_array_each.rb +0 -27
  49. data/benchmarks/for_vs_hash_each.rb +0 -27
  50. data/benchmarks/has_key-vs-lookup.rb +0 -177
  51. data/benchmarks/headers_case_sensitivity.rb +0 -83
  52. data/benchmarks/headers_split_vs_match.rb +0 -34
  53. data/benchmarks/implicit_block-vs-explicit_block.rb +0 -98
  54. data/benchmarks/merging.rb +0 -21
  55. data/benchmarks/single_vs_double_quotes.rb +0 -21
  56. data/benchmarks/string_ranged_index.rb +0 -87
  57. data/benchmarks/strip_newline.rb +0 -115
  58. data/benchmarks/vs_stdlib.rb +0 -82
  59. data/changelog.txt +0 -959
  60. data/lib/excon/errors.rb +0 -172
  61. data/lib/excon/standard_instrumentor.rb +0 -27
  62. data/tests/authorization_header_tests.rb +0 -33
  63. data/tests/bad_tests.rb +0 -47
  64. data/tests/basic_tests.rb +0 -334
  65. data/tests/complete_responses.rb +0 -31
  66. data/tests/data/127.0.0.1.cert.crt +0 -14
  67. data/tests/data/127.0.0.1.cert.key +0 -15
  68. data/tests/data/excon.cert.crt +0 -14
  69. data/tests/data/excon.cert.key +0 -15
  70. data/tests/data/xs +0 -1
  71. data/tests/errors_tests.rb +0 -58
  72. data/tests/header_tests.rb +0 -119
  73. data/tests/middlewares/canned_response_tests.rb +0 -34
  74. data/tests/middlewares/capture_cookies_tests.rb +0 -34
  75. data/tests/middlewares/decompress_tests.rb +0 -157
  76. data/tests/middlewares/escape_path_tests.rb +0 -36
  77. data/tests/middlewares/idempotent_tests.rb +0 -131
  78. data/tests/middlewares/instrumentation_tests.rb +0 -312
  79. data/tests/middlewares/mock_tests.rb +0 -293
  80. data/tests/middlewares/redirect_follower_tests.rb +0 -80
  81. data/tests/pipeline_tests.rb +0 -40
  82. data/tests/proxy_tests.rb +0 -306
  83. data/tests/query_string_tests.rb +0 -87
  84. data/tests/rackups/basic.rb +0 -41
  85. data/tests/rackups/basic.ru +0 -3
  86. data/tests/rackups/basic_auth.ru +0 -14
  87. data/tests/rackups/deflater.ru +0 -4
  88. data/tests/rackups/proxy.ru +0 -18
  89. data/tests/rackups/query_string.ru +0 -13
  90. data/tests/rackups/redirecting.ru +0 -23
  91. data/tests/rackups/redirecting_with_cookie.ru +0 -40
  92. data/tests/rackups/request_headers.ru +0 -15
  93. data/tests/rackups/request_methods.ru +0 -21
  94. data/tests/rackups/response_header.ru +0 -18
  95. data/tests/rackups/ssl.ru +0 -16
  96. data/tests/rackups/ssl_mismatched_cn.ru +0 -15
  97. data/tests/rackups/ssl_verify_peer.ru +0 -16
  98. data/tests/rackups/streaming.ru +0 -30
  99. data/tests/rackups/thread_safety.ru +0 -17
  100. data/tests/rackups/timeout.ru +0 -14
  101. data/tests/rackups/webrick_patch.rb +0 -34
  102. data/tests/request_headers_tests.rb +0 -21
  103. data/tests/request_method_tests.rb +0 -47
  104. data/tests/request_tests.rb +0 -59
  105. data/tests/response_tests.rb +0 -197
  106. data/tests/servers/bad.rb +0 -20
  107. data/tests/servers/eof.rb +0 -17
  108. data/tests/servers/error.rb +0 -20
  109. data/tests/servers/good.rb +0 -350
  110. data/tests/test_helper.rb +0 -306
  111. data/tests/thread_safety_tests.rb +0 -39
  112. data/tests/timeout_tests.rb +0 -12
  113. data/tests/utils_tests.rb +0 -81
@@ -1,21 +0,0 @@
1
- require 'rubygems'
2
- require 'tach'
3
-
4
- Tach.meter(1_000_000) do
5
- tach('double') do
6
- "path"
7
- end
8
- tach('single') do
9
- 'path'
10
- end
11
- end
12
-
13
- # [double, single]
14
- #
15
- # +--------+----------+
16
- # | tach | total |
17
- # +--------+----------+
18
- # | single | 0.416340 |
19
- # +--------+----------+
20
- # | double | 0.416570 |
21
- # +--------+----------+
@@ -1,87 +0,0 @@
1
- # Copied from my benchmark_hell repo: github.com/sgonyea/benchmark_hell
2
-
3
- require 'benchmark'
4
-
5
- iters = 1000000
6
-
7
- string = "Test String OMG"
8
-
9
- puts 'String ranged index vs. "coordinates"'
10
- Benchmark.bmbm do |x|
11
- x.report('ranged index') do
12
- iters.times.each do
13
- text = string[2..9]
14
- end
15
- end
16
-
17
- x.report('coordinates') do
18
- iters.times.each do
19
- text = string[2, 9]
20
- end
21
- end
22
- end
23
-
24
- =begin
25
- rvm exec bash -c 'echo && echo $RUBY_VERSION && echo && ruby string_ranged_index.rb'
26
-
27
-
28
- jruby-1.5.6
29
-
30
- String ranged index vs. "coordinates"
31
- Rehearsal ------------------------------------------------
32
- ranged index 0.419000 0.000000 0.419000 ( 0.372000)
33
- coordinates 0.167000 0.000000 0.167000 ( 0.167000)
34
- --------------------------------------- total: 0.586000sec
35
-
36
- user system total real
37
- ranged index 0.158000 0.000000 0.158000 ( 0.159000)
38
- coordinates 0.125000 0.000000 0.125000 ( 0.125000)
39
-
40
- macruby-0.7.1
41
-
42
- String ranged index vs. "coordinates"
43
- Rehearsal ------------------------------------------------
44
- ranged index 1.490000 0.030000 1.520000 ( 1.061326)
45
- coordinates 1.410000 0.030000 1.440000 ( 0.973640)
46
- --------------------------------------- total: 2.960000sec
47
-
48
- user system total real
49
- ranged index 1.520000 0.030000 1.550000 ( 1.081424)
50
- coordinates 1.480000 0.030000 1.510000 ( 1.029214)
51
-
52
- rbx-head
53
-
54
- String ranged index vs. "coordinates"
55
- Rehearsal ------------------------------------------------
56
- ranged index 1.333304 0.009398 1.342702 ( 1.229629)
57
- coordinates 0.306087 0.000603 0.306690 ( 0.303538)
58
- --------------------------------------- total: 1.649392sec
59
-
60
- user system total real
61
- ranged index 0.923626 0.001597 0.925223 ( 0.927411)
62
- coordinates 0.298910 0.000533 0.299443 ( 0.300255)
63
-
64
- ruby-1.8.7-p330
65
-
66
- String ranged index vs. "coordinates"
67
- Rehearsal ------------------------------------------------
68
- ranged index 0.730000 0.000000 0.730000 ( 0.738612)
69
- coordinates 0.660000 0.000000 0.660000 ( 0.660689)
70
- --------------------------------------- total: 1.390000sec
71
-
72
- user system total real
73
- ranged index 0.750000 0.000000 0.750000 ( 0.746172)
74
- coordinates 0.640000 0.000000 0.640000 ( 0.640687)
75
-
76
- ruby-1.9.2-p136
77
-
78
- String ranged index vs. "coordinates"
79
- Rehearsal ------------------------------------------------
80
- ranged index 0.670000 0.000000 0.670000 ( 0.679046)
81
- coordinates 0.620000 0.000000 0.620000 ( 0.622257)
82
- --------------------------------------- total: 1.290000sec
83
-
84
- user system total real
85
- ranged index 0.680000 0.000000 0.680000 ( 0.686510)
86
- coordinates 0.620000 0.000000 0.620000 ( 0.624269)
87
- =end
@@ -1,115 +0,0 @@
1
- # require 'benchmark'
2
- #
3
- # COUNT = 1_000_000
4
- # data = "Content-Length: 100\r\n"
5
- # Benchmark.bmbm(25) do |bench|
6
- # bench.report('chomp') do
7
- # COUNT.times do
8
- # data = "Content-Length: 100\r\n"
9
- # data.chomp
10
- # end
11
- # end
12
- # bench.report('chomp!') do
13
- # COUNT.times do
14
- # data = "Content-Length: 100\r\n"
15
- # data.chomp!
16
- # end
17
- # end
18
- # bench.report('chop') do
19
- # COUNT.times do
20
- # data = "Content-Length: 100\r\n"
21
- # data.chop
22
- # end
23
- # end
24
- # bench.report('chop!') do
25
- # COUNT.times do
26
- # data = "Content-Length: 100\r\n"
27
- # data.chop!
28
- # end
29
- # end
30
- # bench.report('strip') do
31
- # COUNT.times do
32
- # data = "Content-Length: 100\r\n"
33
- # data.strip
34
- # end
35
- # end
36
- # bench.report('strip!') do
37
- # COUNT.times do
38
- # data = "Content-Length: 100\r\n"
39
- # data.strip!
40
- # end
41
- # end
42
- # bench.report('index') do
43
- # COUNT.times do
44
- # data = "Content-Length: 100\r\n"
45
- # data[0..-3]
46
- # end
47
- # end
48
- # end
49
-
50
-
51
-
52
- # Rehearsal ------------------------------------------------------------
53
- # chomp 0.640000 0.000000 0.640000 ( 0.644043)
54
- # chomp! 0.530000 0.000000 0.530000 ( 0.531415)
55
- # chop 0.620000 0.000000 0.620000 ( 0.624321)
56
- # chop! 0.500000 0.000000 0.500000 ( 0.509146)
57
- # strip 0.640000 0.000000 0.640000 ( 0.638785)
58
- # strip! 0.530000 0.000000 0.530000 ( 0.532196)
59
- # index 0.740000 0.000000 0.740000 ( 0.745742)
60
- # --------------------------------------------------- total: 4.200000sec
61
- #
62
- # user system total real
63
- # chomp 0.640000 0.010000 0.650000 ( 0.647287)
64
- # chomp! 0.530000 0.000000 0.530000 ( 0.532868)
65
- # chop 0.630000 0.000000 0.630000 ( 0.628236)
66
- # chop! 0.520000 0.000000 0.520000 ( 0.522950)
67
- # strip 0.640000 0.000000 0.640000 ( 0.646328)
68
- # strip! 0.520000 0.000000 0.520000 ( 0.532715)
69
- # index 0.740000 0.010000 0.750000 ( 0.771277)
70
-
71
- require 'rubygems'
72
- require 'tach'
73
-
74
- data = "Content-Length: 100\r\n"
75
- Tach.meter(1_000_000) do
76
- tach('chomp') do
77
- data.dup.chomp
78
- end
79
- tach('chomp!') do
80
- data.dup.chomp!
81
- end
82
- tach('chop') do
83
- data.dup.chop
84
- end
85
- tach('chop!') do
86
- data.dup.chop!
87
- end
88
- tach('strip') do
89
- data.dup.strip
90
- end
91
- tach('strip!') do
92
- data.dup.strip!
93
- end
94
- tach('index') do
95
- data.dup[0..-3]
96
- end
97
- end
98
-
99
- # +--------+----------+----------+
100
- # | tach | average | total |
101
- # +--------+----------+----------+
102
- # | chomp | 1.444547 | 1.444547 |
103
- # +--------+----------+----------+
104
- # | chomp! | 1.276813 | 1.276813 |
105
- # +--------+----------+----------+
106
- # | chop | 1.422744 | 1.422744 |
107
- # +--------+----------+----------+
108
- # | chop! | 1.240941 | 1.240941 |
109
- # +--------+----------+----------+
110
- # | strip | 1.444776 | 1.444776 |
111
- # +--------+----------+----------+
112
- # | strip! | 1.266459 | 1.266459 |
113
- # +--------+----------+----------+
114
- # | index | 1.557975 | 1.557975 |
115
- # +--------+----------+----------+
@@ -1,82 +0,0 @@
1
- require 'rubygems' if RUBY_VERSION < '1.9'
2
-
3
- require 'sinatra/base'
4
- require 'tach'
5
-
6
- require File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib', 'excon')
7
-
8
- module Excon
9
- class Server < Sinatra::Base
10
-
11
- def self.run
12
- Rack::Handler::WEBrick.run(
13
- Excon::Server.new,
14
- :Port => 9292,
15
- :AccessLog => [],
16
- :Logger => WEBrick::Log.new(nil, WEBrick::Log::ERROR)
17
- )
18
- end
19
-
20
- get '/data/:amount' do |amount|
21
- 'x' * amount.to_i
22
- end
23
-
24
- end
25
- end
26
-
27
- def with_server(&block)
28
- pid = Process.fork do
29
- Excon::Server.run
30
- end
31
- loop do
32
- sleep(1)
33
- begin
34
- Excon.get('http://localhost:9292/api/foo')
35
- break
36
- rescue
37
- end
38
- end
39
- yield
40
- ensure
41
- Process.kill(9, pid)
42
- end
43
-
44
- require 'net/http'
45
- require 'open-uri'
46
-
47
- url = 'http://localhost:9292/data/1000'
48
-
49
- with_server do
50
-
51
- Tach.meter(100) do
52
-
53
- tach('Excon') do
54
- Excon.get(url).body
55
- end
56
-
57
- # tach('Excon (persistent)') do |times|
58
- # excon = Excon.new(url)
59
- # times.times do
60
- # excon.request(:method => 'get').body
61
- # end
62
- # end
63
-
64
- tach('Net::HTTP') do
65
- # Net::HTTP.get('localhost', '/data/1000', 9292)
66
- Net::HTTP.start('localhost', 9292) {|http| http.get('/data/1000').body }
67
- end
68
-
69
- # tach('Net::HTTP (persistent)') do |times|
70
- # Net::HTTP.start('localhost', 9292) do |http|
71
- # times.times do
72
- # http.get('/data/1000').body
73
- # end
74
- # end
75
- # end
76
-
77
- # tach('open-uri') do
78
- # open(url).read
79
- # end
80
-
81
- end
82
- end