async-http 0.75.0 → 0.77.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/bake/async/http/h2spec.rb +6 -6
- data/bake/async/http.rb +3 -3
- data/lib/async/http/body/finishable.rb +56 -0
- data/lib/async/http/body/hijack.rb +5 -5
- data/lib/async/http/body/pipe.rb +8 -4
- data/lib/async/http/body/writable.rb +4 -95
- data/lib/async/http/body.rb +3 -3
- data/lib/async/http/client.rb +16 -18
- data/lib/async/http/endpoint.rb +10 -10
- data/lib/async/http/internet/instance.rb +1 -1
- data/lib/async/http/internet.rb +5 -5
- data/lib/async/http/middleware/location_redirector.rb +8 -8
- data/lib/async/http/mock/endpoint.rb +2 -2
- data/lib/async/http/mock.rb +1 -1
- data/lib/async/http/protocol/http.rb +2 -2
- data/lib/async/http/protocol/http1/client.rb +19 -6
- data/lib/async/http/protocol/http1/connection.rb +6 -7
- data/lib/async/http/protocol/http1/request.rb +3 -3
- data/lib/async/http/protocol/http1/response.rb +10 -2
- data/lib/async/http/protocol/http1/server.rb +33 -13
- data/lib/async/http/protocol/http1.rb +3 -3
- data/lib/async/http/protocol/http10.rb +1 -1
- data/lib/async/http/protocol/http11.rb +1 -1
- data/lib/async/http/protocol/http2/client.rb +4 -4
- data/lib/async/http/protocol/http2/connection.rb +12 -12
- data/lib/async/http/protocol/http2/input.rb +3 -3
- data/lib/async/http/protocol/http2/output.rb +30 -15
- data/lib/async/http/protocol/http2/request.rb +4 -4
- data/lib/async/http/protocol/http2/response.rb +14 -4
- data/lib/async/http/protocol/http2/server.rb +3 -3
- data/lib/async/http/protocol/http2/stream.rb +15 -7
- data/lib/async/http/protocol/http2.rb +3 -3
- data/lib/async/http/protocol/https.rb +3 -3
- data/lib/async/http/protocol/request.rb +3 -3
- data/lib/async/http/protocol/response.rb +3 -3
- data/lib/async/http/protocol.rb +3 -3
- data/lib/async/http/proxy.rb +4 -3
- data/lib/async/http/reference.rb +2 -2
- data/lib/async/http/relative_location.rb +1 -1
- data/lib/async/http/server.rb +13 -13
- data/lib/async/http/statistics.rb +4 -4
- data/lib/async/http/version.rb +1 -1
- data/lib/async/http.rb +5 -5
- data/readme.md +11 -0
- data/releases.md +11 -0
- data.tar.gz.sig +0 -0
- metadata +7 -8
- metadata.gz.sig +0 -0
- data/lib/async/http/body/delayed.rb +0 -32
- data/lib/async/http/body/slowloris.rb +0 -55
data/lib/async/http/server.rb
CHANGED
@@ -4,12 +4,12 @@
|
|
4
4
|
# Copyright, 2017-2024, by Samuel Williams.
|
5
5
|
# Copyright, 2019, by Brian Morearty.
|
6
6
|
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
7
|
+
require "async"
|
8
|
+
require "io/endpoint"
|
9
|
+
require "protocol/http/middleware"
|
10
|
+
require "traces/provider"
|
11
11
|
|
12
|
-
require_relative
|
12
|
+
require_relative "protocol"
|
13
13
|
|
14
14
|
module Async
|
15
15
|
module HTTP
|
@@ -76,8 +76,8 @@ module Async
|
|
76
76
|
|
77
77
|
Traces::Provider(self) do
|
78
78
|
def call(request)
|
79
|
-
if trace_parent = request.headers[
|
80
|
-
Traces.trace_context = Traces::Context.parse(trace_parent.join, request.headers[
|
79
|
+
if trace_parent = request.headers["traceparent"]
|
80
|
+
Traces.trace_context = Traces::Context.parse(trace_parent.join, request.headers["tracestate"], remote: true)
|
81
81
|
end
|
82
82
|
|
83
83
|
attributes = {
|
@@ -86,25 +86,25 @@ module Async
|
|
86
86
|
'http.authority': request.authority,
|
87
87
|
'http.scheme': request.scheme,
|
88
88
|
'http.path': request.path,
|
89
|
-
'http.user_agent': request.headers[
|
89
|
+
'http.user_agent': request.headers["user-agent"],
|
90
90
|
}
|
91
91
|
|
92
92
|
if length = request.body&.length
|
93
|
-
attributes[
|
93
|
+
attributes["http.request.length"] = length
|
94
94
|
end
|
95
95
|
|
96
96
|
if protocol = request.protocol
|
97
|
-
attributes[
|
97
|
+
attributes["http.protocol"] = protocol
|
98
98
|
end
|
99
99
|
|
100
|
-
Traces.trace(
|
100
|
+
Traces.trace("async.http.server.call", resource: "#{request.method} #{request.path}", attributes: attributes) do |span|
|
101
101
|
super.tap do |response|
|
102
102
|
if status = response&.status
|
103
|
-
span[
|
103
|
+
span["http.status_code"] = status
|
104
104
|
end
|
105
105
|
|
106
106
|
if length = response&.body&.length
|
107
|
-
span[
|
107
|
+
span["http.response.length"] = length
|
108
108
|
end
|
109
109
|
end
|
110
110
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2018-
|
4
|
+
# Copyright, 2018-2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require
|
6
|
+
require "protocol/http/body/wrapper"
|
7
7
|
|
8
|
-
require
|
8
|
+
require "async/clock"
|
9
9
|
|
10
10
|
module Async
|
11
11
|
module HTTP
|
@@ -89,7 +89,7 @@ module Async
|
|
89
89
|
parts << "took #{format_duration(duration)} until first chunk"
|
90
90
|
end
|
91
91
|
|
92
|
-
return parts.join(
|
92
|
+
return parts.join("; ")
|
93
93
|
end
|
94
94
|
|
95
95
|
def inspect
|
data/lib/async/http/version.rb
CHANGED
data/lib/async/http.rb
CHANGED
@@ -3,11 +3,11 @@
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2017-2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require_relative
|
6
|
+
require_relative "http/version"
|
7
7
|
|
8
|
-
require_relative
|
9
|
-
require_relative
|
8
|
+
require_relative "http/client"
|
9
|
+
require_relative "http/server"
|
10
10
|
|
11
|
-
require_relative
|
11
|
+
require_relative "http/internet"
|
12
12
|
|
13
|
-
require_relative
|
13
|
+
require_relative "http/endpoint"
|
data/readme.md
CHANGED
@@ -16,6 +16,17 @@ Please see the [project documentation](https://socketry.github.io/async-http/) f
|
|
16
16
|
|
17
17
|
Please see the [project releases](https://socketry.github.io/async-http/releases/index) for all releases.
|
18
18
|
|
19
|
+
### v0.77.0
|
20
|
+
|
21
|
+
- Improved HTTP/1 connection handling.
|
22
|
+
- The input stream is no longer closed when the output stream is closed.
|
23
|
+
|
24
|
+
### v0.76.0
|
25
|
+
|
26
|
+
- `Async::HTTP::Body::Writable` is moved to `Protocol::HTTP::Body::Writable`.
|
27
|
+
- Remove `Async::HTTP::Body::Delayed` with no replacement.
|
28
|
+
- Remove `Async::HTTP::Body::Slowloris` with no replacement.
|
29
|
+
|
19
30
|
### v0.75.0
|
20
31
|
|
21
32
|
- Better handling of HTTP/1 \<-\> HTTP/2 proxying, specifically upgrade/CONNECT requests.
|
data/releases.md
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
# Releases
|
2
2
|
|
3
|
+
## v0.77.0
|
4
|
+
|
5
|
+
- Improved HTTP/1 connection handling.
|
6
|
+
- The input stream is no longer closed when the output stream is closed.
|
7
|
+
|
8
|
+
## v0.76.0
|
9
|
+
|
10
|
+
- `Async::HTTP::Body::Writable` is moved to `Protocol::HTTP::Body::Writable`.
|
11
|
+
- Remove `Async::HTTP::Body::Delayed` with no replacement.
|
12
|
+
- Remove `Async::HTTP::Body::Slowloris` with no replacement.
|
13
|
+
|
3
14
|
## v0.75.0
|
4
15
|
|
5
16
|
- Better handling of HTTP/1 \<-\> HTTP/2 proxying, specifically upgrade/CONNECT requests.
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async-http
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.77.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -58,7 +58,7 @@ cert_chain:
|
|
58
58
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
59
59
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
60
60
|
-----END CERTIFICATE-----
|
61
|
-
date: 2024-09-
|
61
|
+
date: 2024-09-19 00:00:00.000000000 Z
|
62
62
|
dependencies:
|
63
63
|
- !ruby/object:Gem::Dependency
|
64
64
|
name: async
|
@@ -122,28 +122,28 @@ dependencies:
|
|
122
122
|
requirements:
|
123
123
|
- - "~>"
|
124
124
|
- !ruby/object:Gem::Version
|
125
|
-
version: '0.
|
125
|
+
version: '0.37'
|
126
126
|
type: :runtime
|
127
127
|
prerelease: false
|
128
128
|
version_requirements: !ruby/object:Gem::Requirement
|
129
129
|
requirements:
|
130
130
|
- - "~>"
|
131
131
|
- !ruby/object:Gem::Version
|
132
|
-
version: '0.
|
132
|
+
version: '0.37'
|
133
133
|
- !ruby/object:Gem::Dependency
|
134
134
|
name: protocol-http1
|
135
135
|
requirement: !ruby/object:Gem::Requirement
|
136
136
|
requirements:
|
137
137
|
- - "~>"
|
138
138
|
- !ruby/object:Gem::Version
|
139
|
-
version: '0.
|
139
|
+
version: '0.25'
|
140
140
|
type: :runtime
|
141
141
|
prerelease: false
|
142
142
|
version_requirements: !ruby/object:Gem::Requirement
|
143
143
|
requirements:
|
144
144
|
- - "~>"
|
145
145
|
- !ruby/object:Gem::Version
|
146
|
-
version: '0.
|
146
|
+
version: '0.25'
|
147
147
|
- !ruby/object:Gem::Dependency
|
148
148
|
name: protocol-http2
|
149
149
|
requirement: !ruby/object:Gem::Requirement
|
@@ -182,10 +182,9 @@ files:
|
|
182
182
|
- bake/async/http/h2spec.rb
|
183
183
|
- lib/async/http.rb
|
184
184
|
- lib/async/http/body.rb
|
185
|
-
- lib/async/http/body/
|
185
|
+
- lib/async/http/body/finishable.rb
|
186
186
|
- lib/async/http/body/hijack.rb
|
187
187
|
- lib/async/http/body/pipe.rb
|
188
|
-
- lib/async/http/body/slowloris.rb
|
189
188
|
- lib/async/http/body/writable.rb
|
190
189
|
- lib/async/http/client.rb
|
191
190
|
- lib/async/http/endpoint.rb
|
metadata.gz.sig
CHANGED
Binary file
|
@@ -1,32 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Released under the MIT License.
|
4
|
-
# Copyright, 2018-2023, by Samuel Williams.
|
5
|
-
# Copyright, 2020, by Bruno Sutic.
|
6
|
-
# Copyright, 2023, by Thomas Morgan.
|
7
|
-
|
8
|
-
require 'protocol/http/body/wrapper'
|
9
|
-
|
10
|
-
module Async
|
11
|
-
module HTTP
|
12
|
-
module Body
|
13
|
-
class Delayed < ::Protocol::HTTP::Body::Wrapper
|
14
|
-
def initialize(body, delay = 0.01)
|
15
|
-
super(body)
|
16
|
-
|
17
|
-
@delay = delay
|
18
|
-
end
|
19
|
-
|
20
|
-
def ready?
|
21
|
-
false
|
22
|
-
end
|
23
|
-
|
24
|
-
def read
|
25
|
-
Async::Task.current.sleep(@delay)
|
26
|
-
|
27
|
-
return super
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,55 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Released under the MIT License.
|
4
|
-
# Copyright, 2019-2023, by Samuel Williams.
|
5
|
-
|
6
|
-
require_relative 'writable'
|
7
|
-
|
8
|
-
require 'async/clock'
|
9
|
-
|
10
|
-
module Async
|
11
|
-
module HTTP
|
12
|
-
module Body
|
13
|
-
# A dynamic body which you can write to and read from.
|
14
|
-
class Slowloris < Writable
|
15
|
-
class ThroughputError < StandardError
|
16
|
-
def initialize(throughput, minimum_throughput, time_since_last_write)
|
17
|
-
super("Slow write: #{throughput.round(1)}bytes/s less than required #{minimum_throughput.round}bytes/s.")
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
# In order for this implementation to work correctly, you need to use a LimitedQueue.
|
22
|
-
# @param minimum_throughput [Integer] the minimum bytes per second otherwise this body will be forcefully closed.
|
23
|
-
def initialize(*arguments, minimum_throughput: 1024, **options)
|
24
|
-
super(*arguments, **options)
|
25
|
-
|
26
|
-
@minimum_throughput = minimum_throughput
|
27
|
-
|
28
|
-
@last_write_at = nil
|
29
|
-
@last_chunk_size = nil
|
30
|
-
end
|
31
|
-
|
32
|
-
attr :minimum_throughput
|
33
|
-
|
34
|
-
# If #read is called regularly to maintain throughput, that is good. If #read is not called, that is a problem. Throughput is dependent on data being available, from #write, so it doesn't seem particularly problimatic to do this check in #write.
|
35
|
-
def write(chunk)
|
36
|
-
if @last_chunk_size
|
37
|
-
time_since_last_write = Async::Clock.now - @last_write_at
|
38
|
-
throughput = @last_chunk_size / time_since_last_write
|
39
|
-
|
40
|
-
if throughput < @minimum_throughput
|
41
|
-
error = ThroughputError.new(throughput, @minimum_throughput, time_since_last_write)
|
42
|
-
|
43
|
-
self.close(error)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
super.tap do
|
48
|
-
@last_write_at = Async::Clock.now
|
49
|
-
@last_chunk_size = chunk&.bytesize
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|