async-http-faraday 0.15.0 → 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/async/http/faraday/adapter.rb +18 -3
- data/lib/async/http/faraday/clients.rb +14 -17
- data/lib/async/http/faraday/version.rb +1 -1
- data/license.md +1 -0
- data.tar.gz.sig +0 -0
- metadata +3 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7776d459550575acb11624923ae956bf21f3810a0ffc0017afbcf72b708729f7
|
4
|
+
data.tar.gz: 3542ef8a35ddf61847f83af21386a7b43c42de3d5f4e72d26173293c8031703d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4719795d6ce2bd376d136de090d850cb724c4d6de93e0aa813bd3288cb729332367f6f70525153e4a4f307f6336f4f188d0144caa7811fde978341527e55cefd
|
7
|
+
data.tar.gz: c6b6fbe83e46143c10f426c6b483b7729c4d3e5ba507affd06985abdba7afbec2b5576c53f2ddd0b76beae911a536e61fe6e825126581d19ea15d81296c9286a
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -8,6 +8,7 @@
|
|
8
8
|
# Copyright, 2023, by Genki Takiuchi.
|
9
9
|
# Copyright, 2023, by Flavio Fernandes.
|
10
10
|
# Copyright, 2024, by Jacob Frautschi.
|
11
|
+
# Copyright, 2024, by Korbin Hoffman.
|
11
12
|
|
12
13
|
require 'faraday'
|
13
14
|
require 'faraday/adapter'
|
@@ -119,9 +120,23 @@ module Async
|
|
119
120
|
request = ::Protocol::HTTP::Request.new(endpoint.scheme, endpoint.authority, method, endpoint.path, nil, headers, body)
|
120
121
|
|
121
122
|
with_timeout do
|
122
|
-
|
123
|
-
|
124
|
-
|
123
|
+
if env.stream_response?
|
124
|
+
response = env.stream_response do |&on_data|
|
125
|
+
response = client.call(request)
|
126
|
+
|
127
|
+
response.each do |chunk|
|
128
|
+
on_data.call(chunk)
|
129
|
+
end
|
130
|
+
|
131
|
+
response
|
132
|
+
end
|
133
|
+
|
134
|
+
save_response(env, response.status, nil, response.headers)
|
135
|
+
else
|
136
|
+
response = client.call(request)
|
137
|
+
|
138
|
+
save_response(env, response.status, encoded_body(response), response.headers)
|
139
|
+
end
|
125
140
|
end
|
126
141
|
end
|
127
142
|
|
@@ -1,13 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright,
|
5
|
-
# Copyright, 2018, by Andreas Garnaes.
|
6
|
-
# Copyright, 2019, by Denis Talakevich.
|
7
|
-
# Copyright, 2019-2020, by Igor Sidorov.
|
8
|
-
# Copyright, 2023, by Genki Takiuchi.
|
9
|
-
# Copyright, 2023, by Flavio Fernandes.
|
10
|
-
# Copyright, 2024, by Jacob Frautschi.
|
4
|
+
# Copyright, 2024, by Samuel Williams.
|
11
5
|
|
12
6
|
require 'faraday'
|
13
7
|
require 'faraday/adapter'
|
@@ -66,7 +60,7 @@ module Async
|
|
66
60
|
# @parameter endpoint [IO::Endpoint::Generic] The endpoint to get the client for.
|
67
61
|
# @yields {|client| ...} A client for the given endpoint.
|
68
62
|
def with_proxied_client(proxy_endpoint, endpoint)
|
69
|
-
client =
|
63
|
+
client = make_client(proxy_endpoint)
|
70
64
|
proxied_client = client.proxied_client(endpoint)
|
71
65
|
|
72
66
|
yield proxied_client
|
@@ -95,6 +89,17 @@ module Async
|
|
95
89
|
clients.each(&:close)
|
96
90
|
end
|
97
91
|
|
92
|
+
# Lookup or create a client for the given endpoint.
|
93
|
+
#
|
94
|
+
# @parameter endpoint [IO::Endpoint::Generic] The endpoint to create the client for.
|
95
|
+
def make_client(endpoint)
|
96
|
+
key = host_key(endpoint)
|
97
|
+
|
98
|
+
fetch(key) do
|
99
|
+
super
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
98
103
|
# Get a client for the given endpoint. If a client already exists for the host, it will be reused.
|
99
104
|
#
|
100
105
|
# @yields {|client| ...} A client for the given endpoint.
|
@@ -110,7 +115,7 @@ module Async
|
|
110
115
|
key = [host_key(proxy_endpoint), host_key(endpoint)]
|
111
116
|
|
112
117
|
proxied_client = fetch(key) do
|
113
|
-
|
118
|
+
make_client(proxy_endpoint).proxied_client(endpoint)
|
114
119
|
end
|
115
120
|
|
116
121
|
yield proxied_client
|
@@ -133,14 +138,6 @@ module Async
|
|
133
138
|
|
134
139
|
return url
|
135
140
|
end
|
136
|
-
|
137
|
-
def client_for(endpoint)
|
138
|
-
key = host_key(endpoint)
|
139
|
-
|
140
|
-
fetch(key) do
|
141
|
-
make_client
|
142
|
-
end
|
143
|
-
end
|
144
141
|
end
|
145
142
|
|
146
143
|
# An interface for creating and managing per-thread persistent HTTP clients.
|
data/license.md
CHANGED
@@ -9,6 +9,7 @@ Copyright, 2020, by Benoit Daloze.
|
|
9
9
|
Copyright, 2023, by Genki Takiuchi.
|
10
10
|
Copyright, 2023, by Flavio Fernandes.
|
11
11
|
Copyright, 2024, by Jacob Frautschi.
|
12
|
+
Copyright, 2024, by Korbin Hoffman.
|
12
13
|
|
13
14
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
14
15
|
of this software and associated documentation files (the "Software"), to deal
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async-http-faraday
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.16.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -13,6 +13,7 @@ authors:
|
|
13
13
|
- Denis Talakevich
|
14
14
|
- Flavio Fernandes
|
15
15
|
- Jacob Frautschi
|
16
|
+
- Korbin Hoffman
|
16
17
|
autorequire:
|
17
18
|
bindir: bin
|
18
19
|
cert_chain:
|
@@ -45,7 +46,7 @@ cert_chain:
|
|
45
46
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
46
47
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
47
48
|
-----END CERTIFICATE-----
|
48
|
-
date: 2024-
|
49
|
+
date: 2024-08-13 00:00:00.000000000 Z
|
49
50
|
dependencies:
|
50
51
|
- !ruby/object:Gem::Dependency
|
51
52
|
name: async-http
|
metadata.gz.sig
CHANGED
Binary file
|