-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproxy.rb
More file actions
41 lines (37 loc) · 1.11 KB
/
Copy pathproxy.rb
File metadata and controls
41 lines (37 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# frozen_string_literal: true
shared_examples 'a proxied connection' do |adapter, options|
options ||= {}
proxy_url_kind = options[:proxy]
server_url_kind = options[:server]
raise "no :proxy url option" if proxy_url_kind.to_s.empty?
raise "no :server url option" if server_url_kind.to_s.empty?
before :all do
conn_options = {
headers: {
'X-Faraday-Live' => '1',
user_agent: "Faraday: #{adapter}",
},
proxy: FaradayURLs.server(proxy_url_kind, options[:auth]),
}
reqs_url = FaradayURLs.server(server_url_kind, "requests")
@conn = Faraday.new(reqs_url, conn_options) do |conn|
conn.request :multipart
conn.request :url_encoded
conn.adapter(adapter.key)
end
end
# proxy does not modify https requests
expected = case proxy_url_kind
when :socks_proxy, :socks_auth_proxy
""
else
server_url_kind == :https ? "" : "goproxy (#{proxy_url_kind})"
end
include_examples 'common request tests', server_url_kind, adapter,
response_header: {
'Via' => expected,
},
request_header: {
'Faraday-Proxy' => expected,
}
end