faraday 0.17.6 → 1.0.0.pre.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.md +1 -1
- data/README.md +18 -358
- data/lib/faraday/adapter/em_http.rb +142 -99
- data/lib/faraday/adapter/em_http_ssl_patch.rb +23 -17
- data/lib/faraday/adapter/em_synchrony/parallel_manager.rb +18 -15
- data/lib/faraday/adapter/em_synchrony.rb +104 -60
- data/lib/faraday/adapter/excon.rb +97 -57
- data/lib/faraday/adapter/httpclient.rb +61 -39
- data/lib/faraday/adapter/net_http.rb +103 -51
- data/lib/faraday/adapter/net_http_persistent.rb +49 -28
- data/lib/faraday/adapter/patron.rb +54 -35
- data/lib/faraday/adapter/rack.rb +28 -12
- data/lib/faraday/adapter/test.rb +86 -53
- data/lib/faraday/adapter/typhoeus.rb +4 -1
- data/lib/faraday/adapter.rb +36 -22
- data/lib/faraday/adapter_registry.rb +28 -0
- data/lib/faraday/autoload.rb +47 -36
- data/lib/faraday/connection.rb +321 -179
- data/lib/faraday/dependency_loader.rb +37 -0
- data/lib/faraday/encoders/flat_params_encoder.rb +94 -0
- data/lib/faraday/encoders/nested_params_encoder.rb +171 -0
- data/lib/faraday/error.rb +21 -79
- data/lib/faraday/logging/formatter.rb +92 -0
- data/lib/faraday/middleware.rb +4 -28
- data/lib/faraday/middleware_registry.rb +129 -0
- data/lib/faraday/options/connection_options.rb +22 -0
- data/lib/faraday/options/env.rb +181 -0
- data/lib/faraday/options/proxy_options.rb +28 -0
- data/lib/faraday/options/request_options.rb +21 -0
- data/lib/faraday/options/ssl_options.rb +59 -0
- data/lib/faraday/options.rb +33 -184
- data/lib/faraday/parameters.rb +4 -197
- data/lib/faraday/rack_builder.rb +66 -55
- data/lib/faraday/request/authorization.rb +42 -30
- data/lib/faraday/request/basic_authentication.rb +14 -7
- data/lib/faraday/request/instrumentation.rb +45 -27
- data/lib/faraday/request/multipart.rb +72 -49
- data/lib/faraday/request/retry.rb +197 -171
- data/lib/faraday/request/token_authentication.rb +15 -10
- data/lib/faraday/request/url_encoded.rb +41 -23
- data/lib/faraday/request.rb +68 -38
- data/lib/faraday/response/logger.rb +22 -69
- data/lib/faraday/response/raise_error.rb +36 -18
- data/lib/faraday/response.rb +22 -15
- data/lib/faraday/upload_io.rb +31 -30
- data/lib/faraday/utils/headers.rb +139 -0
- data/lib/faraday/utils/params_hash.rb +61 -0
- data/lib/faraday/utils.rb +28 -245
- data/lib/faraday.rb +93 -174
- data/spec/external_adapters/faraday_specs_setup.rb +14 -0
- metadata +25 -51
- data/CHANGELOG.md +0 -232
- data/Rakefile +0 -13
- data/lib/faraday/deprecate.rb +0 -109
- data/spec/faraday/deprecate_spec.rb +0 -147
- data/spec/faraday/error_spec.rb +0 -102
- data/spec/faraday/response/raise_error_spec.rb +0 -106
- data/spec/spec_helper.rb +0 -105
- data/test/adapters/default_test.rb +0 -14
- data/test/adapters/em_http_test.rb +0 -30
- data/test/adapters/em_synchrony_test.rb +0 -32
- data/test/adapters/excon_test.rb +0 -30
- data/test/adapters/httpclient_test.rb +0 -34
- data/test/adapters/integration.rb +0 -263
- data/test/adapters/logger_test.rb +0 -136
- data/test/adapters/net_http_persistent_test.rb +0 -114
- data/test/adapters/net_http_test.rb +0 -79
- data/test/adapters/patron_test.rb +0 -40
- data/test/adapters/rack_test.rb +0 -38
- data/test/adapters/test_middleware_test.rb +0 -157
- data/test/adapters/typhoeus_test.rb +0 -38
- data/test/authentication_middleware_test.rb +0 -65
- data/test/composite_read_io_test.rb +0 -109
- data/test/connection_test.rb +0 -738
- data/test/env_test.rb +0 -268
- data/test/helper.rb +0 -75
- data/test/live_server.rb +0 -67
- data/test/middleware/instrumentation_test.rb +0 -88
- data/test/middleware/retry_test.rb +0 -282
- data/test/middleware_stack_test.rb +0 -260
- data/test/multibyte.txt +0 -1
- data/test/options_test.rb +0 -333
- data/test/parameters_test.rb +0 -157
- data/test/request_middleware_test.rb +0 -126
- data/test/response_middleware_test.rb +0 -72
- data/test/strawberry.rb +0 -2
- data/test/utils_test.rb +0 -98
@@ -1,109 +0,0 @@
|
|
1
|
-
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
|
2
|
-
require 'stringio'
|
3
|
-
|
4
|
-
class CompositeReadIOTest < Faraday::TestCase
|
5
|
-
Part = Struct.new(:to_io) do
|
6
|
-
def length() to_io.string.length end
|
7
|
-
end
|
8
|
-
|
9
|
-
def part(str)
|
10
|
-
Part.new StringIO.new(str)
|
11
|
-
end
|
12
|
-
|
13
|
-
def composite_io(*parts)
|
14
|
-
Faraday::CompositeReadIO.new(*parts)
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_empty
|
18
|
-
io = composite_io
|
19
|
-
assert_equal 0, io.length
|
20
|
-
assert_equal "", io.read
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_empty_returns_nil_for_limited_read
|
24
|
-
assert_nil composite_io.read(1)
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_empty_parts_returns_nil_for_limited_read
|
28
|
-
io = composite_io(part(""), part(""))
|
29
|
-
assert_nil io.read(1)
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_multipart_read_all
|
33
|
-
io = composite_io(part("abcd"), part("1234"))
|
34
|
-
assert_equal 8, io.length
|
35
|
-
assert_equal "abcd1234", io.read
|
36
|
-
end
|
37
|
-
|
38
|
-
def test_multipart_read_limited
|
39
|
-
io = composite_io(part("abcd"), part("1234"))
|
40
|
-
assert_equal "abc", io.read(3)
|
41
|
-
assert_equal "d12", io.read(3)
|
42
|
-
assert_equal "34", io.read(3)
|
43
|
-
assert_nil io.read(3)
|
44
|
-
assert_nil io.read(3)
|
45
|
-
end
|
46
|
-
|
47
|
-
def test_multipart_read_limited_size_larger_than_part
|
48
|
-
io = composite_io(part("abcd"), part("1234"))
|
49
|
-
assert_equal "abcd12", io.read(6)
|
50
|
-
assert_equal "34", io.read(6)
|
51
|
-
assert_nil io.read(6)
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_multipart_read_with_blank_parts
|
55
|
-
io = composite_io(part(""), part("abcd"), part(""), part("1234"), part(""))
|
56
|
-
assert_equal "abcd12", io.read(6)
|
57
|
-
assert_equal "34", io.read(6)
|
58
|
-
assert_nil io.read(6)
|
59
|
-
end
|
60
|
-
|
61
|
-
def test_multipart_rewind
|
62
|
-
io = composite_io(part("abcd"), part("1234"))
|
63
|
-
assert_equal "abc", io.read(3)
|
64
|
-
assert_equal "d12", io.read(3)
|
65
|
-
io.rewind
|
66
|
-
assert_equal "abc", io.read(3)
|
67
|
-
assert_equal "d1234", io.read(5)
|
68
|
-
assert_nil io.read(3)
|
69
|
-
io.rewind
|
70
|
-
assert_equal "ab", io.read(2)
|
71
|
-
end
|
72
|
-
|
73
|
-
# JRuby enforces types to copy_stream to be String or IO
|
74
|
-
if IO.respond_to?(:copy_stream) && !jruby?
|
75
|
-
def test_compatible_with_copy_stream
|
76
|
-
target_io = StringIO.new
|
77
|
-
def target_io.ensure_open_and_writable
|
78
|
-
# Rubinius compatibility
|
79
|
-
end
|
80
|
-
io = composite_io(part("abcd"), part("1234"))
|
81
|
-
|
82
|
-
Faraday::Timer.timeout(1) do
|
83
|
-
IO.copy_stream(io, target_io)
|
84
|
-
end
|
85
|
-
assert_equal "abcd1234", target_io.string
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
def test_read_from_multibyte
|
90
|
-
File.open(File.dirname(__FILE__) + '/multibyte.txt') do |utf8|
|
91
|
-
io = composite_io(part("\x86"), Part.new(utf8))
|
92
|
-
assert_equal bin("\x86\xE3\x83\x95\xE3\x82\xA1\xE3\x82\xA4\xE3\x83\xAB\n"), io.read
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
def test_limited_from_multibyte
|
97
|
-
File.open(File.dirname(__FILE__) + '/multibyte.txt') do |utf8|
|
98
|
-
io = composite_io(part("\x86"), Part.new(utf8))
|
99
|
-
assert_equal bin("\x86\xE3\x83"), io.read(3)
|
100
|
-
assert_equal bin("\x95\xE3\x82"), io.read(3)
|
101
|
-
assert_equal bin("\xA1\xE3\x82\xA4\xE3\x83\xAB\n"), io.read(8)
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
def bin(str)
|
106
|
-
str.force_encoding("BINARY") if str.respond_to?(:force_encoding)
|
107
|
-
str
|
108
|
-
end
|
109
|
-
end
|