async-http 0.75.0 → 0.77.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/bake/async/http/h2spec.rb +6 -6
  4. data/bake/async/http.rb +3 -3
  5. data/lib/async/http/body/finishable.rb +56 -0
  6. data/lib/async/http/body/hijack.rb +5 -5
  7. data/lib/async/http/body/pipe.rb +8 -4
  8. data/lib/async/http/body/writable.rb +4 -95
  9. data/lib/async/http/body.rb +3 -3
  10. data/lib/async/http/client.rb +16 -18
  11. data/lib/async/http/endpoint.rb +10 -10
  12. data/lib/async/http/internet/instance.rb +1 -1
  13. data/lib/async/http/internet.rb +5 -5
  14. data/lib/async/http/middleware/location_redirector.rb +8 -8
  15. data/lib/async/http/mock/endpoint.rb +2 -2
  16. data/lib/async/http/mock.rb +1 -1
  17. data/lib/async/http/protocol/http.rb +2 -2
  18. data/lib/async/http/protocol/http1/client.rb +19 -6
  19. data/lib/async/http/protocol/http1/connection.rb +6 -7
  20. data/lib/async/http/protocol/http1/request.rb +3 -3
  21. data/lib/async/http/protocol/http1/response.rb +10 -2
  22. data/lib/async/http/protocol/http1/server.rb +33 -13
  23. data/lib/async/http/protocol/http1.rb +3 -3
  24. data/lib/async/http/protocol/http10.rb +1 -1
  25. data/lib/async/http/protocol/http11.rb +1 -1
  26. data/lib/async/http/protocol/http2/client.rb +4 -4
  27. data/lib/async/http/protocol/http2/connection.rb +12 -12
  28. data/lib/async/http/protocol/http2/input.rb +3 -3
  29. data/lib/async/http/protocol/http2/output.rb +30 -15
  30. data/lib/async/http/protocol/http2/request.rb +4 -4
  31. data/lib/async/http/protocol/http2/response.rb +14 -4
  32. data/lib/async/http/protocol/http2/server.rb +3 -3
  33. data/lib/async/http/protocol/http2/stream.rb +15 -7
  34. data/lib/async/http/protocol/http2.rb +3 -3
  35. data/lib/async/http/protocol/https.rb +3 -3
  36. data/lib/async/http/protocol/request.rb +3 -3
  37. data/lib/async/http/protocol/response.rb +3 -3
  38. data/lib/async/http/protocol.rb +3 -3
  39. data/lib/async/http/proxy.rb +4 -3
  40. data/lib/async/http/reference.rb +2 -2
  41. data/lib/async/http/relative_location.rb +1 -1
  42. data/lib/async/http/server.rb +13 -13
  43. data/lib/async/http/statistics.rb +4 -4
  44. data/lib/async/http/version.rb +1 -1
  45. data/lib/async/http.rb +5 -5
  46. data/readme.md +11 -0
  47. data/releases.md +11 -0
  48. data.tar.gz.sig +0 -0
  49. metadata +7 -8
  50. metadata.gz.sig +0 -0
  51. data/lib/async/http/body/delayed.rb +0 -32
  52. data/lib/async/http/body/slowloris.rb +0 -55
@@ -4,12 +4,12 @@
4
4
  # Copyright, 2017-2024, by Samuel Williams.
5
5
  # Copyright, 2019, by Brian Morearty.
6
6
 
7
- require 'async'
8
- require 'io/endpoint'
9
- require 'protocol/http/middleware'
10
- require 'traces/provider'
7
+ require "async"
8
+ require "io/endpoint"
9
+ require "protocol/http/middleware"
10
+ require "traces/provider"
11
11
 
12
- require_relative 'protocol'
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['traceparent']
80
- Traces.trace_context = Traces::Context.parse(trace_parent.join, request.headers['tracestate'], remote: true)
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['user-agent'],
89
+ 'http.user_agent': request.headers["user-agent"],
90
90
  }
91
91
 
92
92
  if length = request.body&.length
93
- attributes['http.request.length'] = length
93
+ attributes["http.request.length"] = length
94
94
  end
95
95
 
96
96
  if protocol = request.protocol
97
- attributes['http.protocol'] = protocol
97
+ attributes["http.protocol"] = protocol
98
98
  end
99
99
 
100
- Traces.trace('async.http.server.call', resource: "#{request.method} #{request.path}", attributes: attributes) do |span|
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['http.status_code'] = status
103
+ span["http.status_code"] = status
104
104
  end
105
105
 
106
106
  if length = response&.body&.length
107
- span['http.response.length'] = length
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-2023, by Samuel Williams.
4
+ # Copyright, 2018-2024, by Samuel Williams.
5
5
 
6
- require 'protocol/http/body/wrapper'
6
+ require "protocol/http/body/wrapper"
7
7
 
8
- require 'async/clock'
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
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Async
7
7
  module HTTP
8
- VERSION = "0.75.0"
8
+ VERSION = "0.77.0"
9
9
  end
10
10
  end
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 'http/version'
6
+ require_relative "http/version"
7
7
 
8
- require_relative 'http/client'
9
- require_relative 'http/server'
8
+ require_relative "http/client"
9
+ require_relative "http/server"
10
10
 
11
- require_relative 'http/internet'
11
+ require_relative "http/internet"
12
12
 
13
- require_relative 'http/endpoint'
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 \&lt;-\&gt; 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.75.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-04 00:00:00.000000000 Z
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.30'
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.30'
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.20'
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.20'
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/delayed.rb
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