excon 0.62.0 → 0.92.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. checksums.yaml +5 -5
  2. data/CONTRIBUTING.md +0 -1
  3. data/LICENSE.md +1 -1
  4. data/README.md +7 -6
  5. data/data/cacert.pem +1220 -1828
  6. data/excon.gemspec +19 -3
  7. data/lib/excon/connection.rb +216 -139
  8. data/lib/excon/constants.rb +38 -13
  9. data/lib/excon/error.rb +15 -0
  10. data/lib/excon/headers.rb +4 -3
  11. data/lib/excon/instrumentors/logging_instrumentor.rb +5 -16
  12. data/lib/excon/instrumentors/standard_instrumentor.rb +2 -9
  13. data/lib/excon/middlewares/base.rb +6 -0
  14. data/lib/excon/middlewares/capture_cookies.rb +1 -1
  15. data/lib/excon/middlewares/decompress.rb +11 -4
  16. data/lib/excon/middlewares/expects.rb +7 -1
  17. data/lib/excon/middlewares/idempotent.rb +20 -3
  18. data/lib/excon/middlewares/instrumentor.rb +8 -0
  19. data/lib/excon/middlewares/mock.rb +12 -3
  20. data/lib/excon/middlewares/redirect_follower.rb +25 -3
  21. data/lib/excon/middlewares/response_parser.rb +3 -0
  22. data/lib/excon/pretty_printer.rb +1 -8
  23. data/lib/excon/response.rb +12 -9
  24. data/lib/excon/socket.rb +59 -42
  25. data/lib/excon/ssl_socket.rb +37 -15
  26. data/lib/excon/test/plugin/server/exec.rb +5 -2
  27. data/lib/excon/test/plugin/server/puma.rb +4 -1
  28. data/lib/excon/test/plugin/server/unicorn.rb +5 -0
  29. data/lib/excon/test/plugin/server/webrick.rb +4 -1
  30. data/lib/excon/test/server.rb +1 -1
  31. data/lib/excon/unix_socket.rb +1 -0
  32. data/lib/excon/utils.rb +59 -5
  33. data/lib/excon/version.rb +1 -1
  34. data/lib/excon.rb +25 -17
  35. metadata +27 -98
  36. data/.document +0 -5
  37. data/.gitignore +0 -13
  38. data/.rspec +0 -3
  39. data/.travis.yml +0 -29
  40. data/Gemfile +0 -19
  41. data/Rakefile +0 -41
  42. data/benchmarks/class_vs_lambda.rb +0 -50
  43. data/benchmarks/concat_vs_insert.rb +0 -21
  44. data/benchmarks/concat_vs_interpolate.rb +0 -22
  45. data/benchmarks/cr_lf.rb +0 -21
  46. data/benchmarks/downcase-eq-eq_vs_casecmp.rb +0 -169
  47. data/benchmarks/excon.rb +0 -69
  48. data/benchmarks/excon_vs.rb +0 -165
  49. data/benchmarks/for_vs_array_each.rb +0 -27
  50. data/benchmarks/for_vs_hash_each.rb +0 -27
  51. data/benchmarks/has_key-vs-lookup.rb +0 -177
  52. data/benchmarks/headers_case_sensitivity.rb +0 -83
  53. data/benchmarks/headers_split_vs_match.rb +0 -34
  54. data/benchmarks/implicit_block-vs-explicit_block.rb +0 -98
  55. data/benchmarks/merging.rb +0 -21
  56. data/benchmarks/single_vs_double_quotes.rb +0 -21
  57. data/benchmarks/string_ranged_index.rb +0 -87
  58. data/benchmarks/strip_newline.rb +0 -115
  59. data/benchmarks/vs_stdlib.rb +0 -82
  60. data/changelog.txt +0 -1083
  61. data/spec/excon/error_spec.rb +0 -139
  62. data/spec/excon/test/server_spec.rb +0 -28
  63. data/spec/excon_spec.rb +0 -7
  64. data/spec/helpers/file_path_helpers.rb +0 -22
  65. data/spec/requests/basic_spec.rb +0 -40
  66. data/spec/requests/eof_requests_spec.rb +0 -36
  67. data/spec/requests/unix_socket_spec.rb +0 -46
  68. data/spec/spec_helper.rb +0 -24
  69. data/spec/support/shared_contexts/test_server_context.rb +0 -83
  70. data/spec/support/shared_examples/shared_example_for_clients.rb +0 -218
  71. data/spec/support/shared_examples/shared_example_for_streaming_clients.rb +0 -20
  72. data/spec/support/shared_examples/shared_example_for_test_servers.rb +0 -16
  73. data/tests/authorization_header_tests.rb +0 -29
  74. data/tests/bad_tests.rb +0 -47
  75. data/tests/basic_tests.rb +0 -351
  76. data/tests/batch_requests.rb +0 -133
  77. data/tests/complete_responses.rb +0 -31
  78. data/tests/data/127.0.0.1.cert.crt +0 -20
  79. data/tests/data/127.0.0.1.cert.key +0 -27
  80. data/tests/data/excon.cert.crt +0 -20
  81. data/tests/data/excon.cert.key +0 -27
  82. data/tests/data/xs +0 -1
  83. data/tests/error_tests.rb +0 -145
  84. data/tests/header_tests.rb +0 -119
  85. data/tests/middlewares/canned_response_tests.rb +0 -34
  86. data/tests/middlewares/capture_cookies_tests.rb +0 -34
  87. data/tests/middlewares/decompress_tests.rb +0 -157
  88. data/tests/middlewares/escape_path_tests.rb +0 -36
  89. data/tests/middlewares/idempotent_tests.rb +0 -206
  90. data/tests/middlewares/instrumentation_tests.rb +0 -315
  91. data/tests/middlewares/mock_tests.rb +0 -304
  92. data/tests/middlewares/redirect_follower_tests.rb +0 -112
  93. data/tests/pipeline_tests.rb +0 -40
  94. data/tests/proxy_tests.rb +0 -306
  95. data/tests/query_string_tests.rb +0 -87
  96. data/tests/rackups/basic.rb +0 -41
  97. data/tests/rackups/basic.ru +0 -3
  98. data/tests/rackups/basic_auth.ru +0 -14
  99. data/tests/rackups/deflater.ru +0 -4
  100. data/tests/rackups/proxy.ru +0 -18
  101. data/tests/rackups/query_string.ru +0 -13
  102. data/tests/rackups/redirecting.ru +0 -23
  103. data/tests/rackups/redirecting_with_cookie.ru +0 -40
  104. data/tests/rackups/request_headers.ru +0 -15
  105. data/tests/rackups/request_methods.ru +0 -21
  106. data/tests/rackups/response_header.ru +0 -18
  107. data/tests/rackups/ssl.ru +0 -16
  108. data/tests/rackups/ssl_mismatched_cn.ru +0 -15
  109. data/tests/rackups/ssl_verify_peer.ru +0 -16
  110. data/tests/rackups/streaming.ru +0 -30
  111. data/tests/rackups/thread_safety.ru +0 -17
  112. data/tests/rackups/timeout.ru +0 -14
  113. data/tests/rackups/webrick_patch.rb +0 -34
  114. data/tests/request_headers_tests.rb +0 -21
  115. data/tests/request_method_tests.rb +0 -47
  116. data/tests/request_tests.rb +0 -59
  117. data/tests/response_tests.rb +0 -197
  118. data/tests/servers/bad.rb +0 -20
  119. data/tests/servers/eof.rb +0 -17
  120. data/tests/servers/error.rb +0 -20
  121. data/tests/servers/good.rb +0 -350
  122. data/tests/test_helper.rb +0 -306
  123. data/tests/thread_safety_tests.rb +0 -39
  124. data/tests/timeout_tests.rb +0 -12
  125. data/tests/utils_tests.rb +0 -81
@@ -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