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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a24c51b0aca4a4243f088331a3731da8792287fe94f30e1b2d6f398dd521a238
4
- data.tar.gz: '0687f09a3bc87ab6989b4cabc108aff16e21c606755c04fd77112afc40d4d124'
3
+ metadata.gz: 7776d459550575acb11624923ae956bf21f3810a0ffc0017afbcf72b708729f7
4
+ data.tar.gz: 3542ef8a35ddf61847f83af21386a7b43c42de3d5f4e72d26173293c8031703d
5
5
  SHA512:
6
- metadata.gz: ed876ca460be8b0e402240081ab6dcc9318af3e1dce3e34787c40e3bee45fff6e472bb72f30babc666d8ad7660f688d066903f09a253dfc70081fcc2d76e95ca
7
- data.tar.gz: a1dc04a882e162e15c9161cddd48c298e027ed83fb2d5e09a0438f925277e7ad139e0f4577c13ca47f2f0164bde3a9e830cb1062a6eecbc84dbcbc52350cf785
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
- response = client.call(request)
123
-
124
- save_response(env, response.status, encoded_body(response), response.headers)
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, 2018-2024, by Samuel Williams.
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 = client_for(proxy_endpoint)
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
- client_for(proxy_endpoint).proxied_client(endpoint)
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.
@@ -6,7 +6,7 @@
6
6
  module Async
7
7
  module HTTP
8
8
  module Faraday
9
- VERSION = "0.15.0"
9
+ VERSION = "0.16.0"
10
10
  end
11
11
  end
12
12
  end
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.15.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-07-31 00:00:00.000000000 Z
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