async-http 0.60.1 → 0.61.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/bake/async/http/h2spec.rb +4 -0
  4. data/bake/async/http.rb +4 -0
  5. data/lib/async/http/body/delayed.rb +6 -21
  6. data/lib/async/http/body/hijack.rb +3 -20
  7. data/lib/async/http/body/pipe.rb +4 -20
  8. data/lib/async/http/body/slowloris.rb +3 -20
  9. data/lib/async/http/body/writable.rb +3 -20
  10. data/lib/async/http/body.rb +3 -20
  11. data/lib/async/http/client.rb +6 -22
  12. data/lib/async/http/endpoint.rb +8 -20
  13. data/lib/async/http/internet/instance.rb +3 -20
  14. data/lib/async/http/internet.rb +3 -20
  15. data/lib/async/http/protocol/http1/client.rb +3 -20
  16. data/lib/async/http/protocol/http1/connection.rb +3 -20
  17. data/lib/async/http/protocol/http1/request.rb +7 -20
  18. data/lib/async/http/protocol/http1/response.rb +15 -24
  19. data/lib/async/http/protocol/http1/server.rb +11 -22
  20. data/lib/async/http/protocol/http1.rb +3 -20
  21. data/lib/async/http/protocol/http10.rb +3 -20
  22. data/lib/async/http/protocol/http11.rb +4 -20
  23. data/lib/async/http/protocol/http2/client.rb +3 -20
  24. data/lib/async/http/protocol/http2/connection.rb +4 -20
  25. data/lib/async/http/protocol/http2/input.rb +3 -20
  26. data/lib/async/http/protocol/http2/output.rb +3 -20
  27. data/lib/async/http/protocol/http2/request.rb +13 -20
  28. data/lib/async/http/protocol/http2/response.rb +9 -20
  29. data/lib/async/http/protocol/http2/server.rb +3 -20
  30. data/lib/async/http/protocol/http2/stream.rb +8 -26
  31. data/lib/async/http/protocol/http2.rb +3 -20
  32. data/lib/async/http/protocol/https.rb +4 -20
  33. data/lib/async/http/protocol/request.rb +6 -20
  34. data/lib/async/http/protocol/response.rb +3 -20
  35. data/lib/async/http/protocol.rb +3 -20
  36. data/lib/async/http/proxy.rb +3 -20
  37. data/lib/async/http/reference.rb +3 -20
  38. data/lib/async/http/relative_location.rb +5 -19
  39. data/lib/async/http/server.rb +6 -22
  40. data/lib/async/http/statistics.rb +3 -20
  41. data/lib/async/http/version.rb +4 -21
  42. data/lib/async/http.rb +3 -20
  43. data/license.md +38 -0
  44. data/readme.md +384 -0
  45. data.tar.gz.sig +0 -0
  46. metadata +16 -96
  47. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 060e953e1dd2147ecd63186586ba6f59197831fd724a935754d9067ac29a89da
4
- data.tar.gz: d48482ec9783c65f5cfbbf769118c800ab6e5097e236f5e56180904eedaeaed7
3
+ metadata.gz: c7cae098a41e0baff0683a5cd61f620df474d69e07f3aec081a9460e7eeb4efb
4
+ data.tar.gz: 46f0c3eb2ae7b8b1d008df29e4a73ee40b35a301dba47f21091b010ba340b1ae
5
5
  SHA512:
6
- metadata.gz: 6a81332d93c956437723dfa4a2bc82652cee643856f4744ca52b8497fb6cfc9f3e1ef055511f7ca6ed869a495c99efda8e9561a11a0b935484bd78bb0963f07d
7
- data.tar.gz: 28b888a63dc78f62bab033ff8ac7ebeb486ad4c8109147a2bfebb402af946bd557dc0235df603ea30e2fccb43c74844927e450774e281afdfa3baabc2d93433a
6
+ metadata.gz: 71080112751d4f8fe86b4b3b4cd6edf4fe1e1d5ecb6d5832baab507f623dbf901395a5047f0b4e28e26456593e8349cd487bf82d9c6a47bae38e26127b2f86d8
7
+ data.tar.gz: c0dfc8d18959882748664fdf2d5d0d43cced5c6bd8fd1475ea77f3844f4b8ea65311033b870f9ad16345f5683292ba02d25c132f999639957606eb43fcb94c16
checksums.yaml.gz.sig CHANGED
Binary file
@@ -1,3 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2019-2023, by Samuel Williams.
1
5
 
2
6
  def build
3
7
  # Fetch the code:
data/bake/async/http.rb CHANGED
@@ -1,3 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2020-2023, by Samuel Williams.
1
5
 
2
6
  # Fetch the specified URL and print the response.
3
7
  # @param url [String] the URL to parse and fetch.
@@ -1,31 +1,16 @@
1
1
  # frozen_string_literal: true
2
- #
3
- # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
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.
22
7
 
23
8
  require 'protocol/http/body/wrapper'
24
9
 
25
10
  module Async
26
11
  module HTTP
27
12
  module Body
28
- class Delayed < Protocol::HTTP::Body::Wrapper
13
+ class Delayed < ::Protocol::HTTP::Body::Wrapper
29
14
  def initialize(body, delay = 0.01)
30
15
  super(body)
31
16
 
@@ -1,24 +1,7 @@
1
1
  # frozen_string_literal: true
2
- #
3
- # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2019-2023, by Samuel Williams.
22
5
 
23
6
  require 'protocol/http/body/readable'
24
7
  require 'protocol/http/body/stream'
@@ -1,24 +1,8 @@
1
1
  # frozen_string_literal: true
2
- #
3
- # Copyright, 2019, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2019-2023, by Samuel Williams.
5
+ # Copyright, 2020, by Bruno Sutic.
22
6
 
23
7
  require 'async/io/socket'
24
8
  require 'async/io/stream'
@@ -1,24 +1,7 @@
1
1
  # frozen_string_literal: true
2
- #
3
- # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2019-2023, by Samuel Williams.
22
5
 
23
6
  require_relative 'writable'
24
7
 
@@ -1,24 +1,7 @@
1
1
  # frozen_string_literal: true
2
- #
3
- # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2018-2023, by Samuel Williams.
22
5
 
23
6
  require 'protocol/http/body/readable'
24
7
  require 'async/queue'
@@ -1,24 +1,7 @@
1
1
  # frozen_string_literal: true
2
- #
3
- # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2018-2023, by Samuel Williams.
22
5
 
23
6
  require 'protocol/http/body/buffered'
24
7
  require_relative 'body/writable'
@@ -1,24 +1,8 @@
1
1
  # frozen_string_literal: true
2
- #
3
- # Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2017-2023, by Samuel Williams.
5
+ # Copyright, 2022, by Ian Ker-Seymer.
22
6
 
23
7
  require 'async/io/endpoint'
24
8
  require 'async/io/stream'
@@ -160,8 +144,8 @@ module Async
160
144
  attributes['http.request.length'] = length
161
145
  end
162
146
 
163
- trace('async.http.client.call', attributes: attributes) do |span|
164
- if context = self.trace_context
147
+ Traces.trace('async.http.client.call', attributes: attributes) do |span|
148
+ if context = Traces.trace_context
165
149
  request.headers['traceparent'] = context.to_s
166
150
  # request.headers['tracestate'] = context.state
167
151
  end
@@ -1,24 +1,8 @@
1
1
  # frozen_string_literal: true
2
- #
3
- # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2019-2023, by Samuel Williams.
5
+ # Copyright, 2021-2022, by Adam Daniels.
22
6
 
23
7
  require 'async/io/host_endpoint'
24
8
  require 'async/io/ssl_endpoint'
@@ -193,6 +177,10 @@ module Async
193
177
  @endpoint ||= build_endpoint
194
178
  end
195
179
 
180
+ def endpoint=(endpoint)
181
+ @endpoint = build_endpoint(endpoint)
182
+ end
183
+
196
184
  def bind(*arguments, &block)
197
185
  endpoint.bind(*arguments, &block)
198
186
  end
@@ -1,24 +1,7 @@
1
1
  # frozen_string_literal: true
2
- #
3
- # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2021-2023, by Samuel Williams.
22
5
 
23
6
  require_relative '../internet'
24
7
  require 'thread/local'
@@ -1,24 +1,7 @@
1
1
  # frozen_string_literal: true
2
- #
3
- # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2018-2023, by Samuel Williams.
22
5
 
23
6
  require_relative 'client'
24
7
  require_relative 'endpoint'
@@ -1,24 +1,7 @@
1
1
  # frozen_string_literal: true
2
- #
3
- # Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2018-2023, by Samuel Williams.
22
5
 
23
6
  require_relative 'connection'
24
7
 
@@ -1,24 +1,7 @@
1
1
  # frozen_string_literal: true
2
- #
3
- # Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2018-2023, by Samuel Williams.
22
5
 
23
6
  require 'protocol/http1'
24
7
 
@@ -1,24 +1,7 @@
1
1
  # frozen_string_literal: true
2
- #
3
- # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2018-2023, by Samuel Williams.
22
5
 
23
6
  require_relative '../request'
24
7
 
@@ -55,6 +38,10 @@ module Async
55
38
  def hijack!
56
39
  @connection.hijack!
57
40
  end
41
+
42
+ def write_interim_response(response)
43
+ @connection.write_interim_response(response.version, response.status, response.headers)
44
+ end
58
45
  end
59
46
  end
60
47
  end
@@ -1,24 +1,7 @@
1
1
  # frozen_string_literal: true
2
- #
3
- # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2018-2023, by Samuel Williams.
22
5
 
23
6
  require_relative '../response'
24
7
 
@@ -28,16 +11,24 @@ module Async
28
11
  module HTTP1
29
12
  class Response < Protocol::Response
30
13
  def self.read(connection, request)
31
- if parts = connection.read_response(request.method)
32
- self.new(connection, *parts)
14
+ while parts = connection.read_response(request.method)
15
+ response = self.new(connection, *parts)
16
+
17
+ if response.final?
18
+ return response
19
+ end
33
20
  end
34
21
  end
35
22
 
36
23
  UPGRADE = 'upgrade'
37
-
38
- # @param reason [String] HTTP response line reason, ignored.
24
+
25
+ # @attribute [String] The HTTP response line reason.
26
+ attr :reason
27
+
28
+ # @parameter reason [String] HTTP response line reason phrase.
39
29
  def initialize(connection, version, status, reason, headers, body)
40
30
  @connection = connection
31
+ @reason = reason
41
32
 
42
33
  protocol = headers.delete(UPGRADE)
43
34
 
@@ -1,24 +1,9 @@
1
1
  # frozen_string_literal: true
2
- #
3
- # Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2018-2023, by Samuel Williams.
5
+ # Copyright, 2020, by Igor Sidorov.
6
+ # Copyright, 2023, by Thomas Morgan.
22
7
 
23
8
  require_relative 'connection'
24
9
 
@@ -30,6 +15,9 @@ module Async
30
15
  def fail_request(status)
31
16
  @persistent = false
32
17
  write_response(@version, status, {}, nil)
18
+ write_body(@version, nil)
19
+ rescue Errno::ECONNRESET, Errno::EPIPE
20
+ # Handle when connection is already closed
33
21
  end
34
22
 
35
23
  def next_request
@@ -95,7 +83,7 @@ module Async
95
83
  version = request.version
96
84
 
97
85
  # Same as above:
98
- request = nil unless body
86
+ request = nil unless request.body
99
87
  response = nil
100
88
 
101
89
  write_body(version, body, head, trailer)
@@ -110,7 +98,7 @@ module Async
110
98
  end
111
99
 
112
100
  # Gracefully finish reading the request body if it was not already done so.
113
- request&.finish
101
+ request&.each{}
114
102
 
115
103
  # This ensures we yield at least once every iteration of the loop and allow other fibers to execute.
116
104
  task.yield
@@ -121,6 +109,7 @@ module Async
121
109
  end
122
110
  end
123
111
  end
112
+
124
113
  end
125
114
  end
126
115
  end
@@ -1,24 +1,7 @@
1
1
  # frozen_string_literal: true
2
- #
3
- # Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2017-2023, by Samuel Williams.
22
5
 
23
6
  require_relative 'http1/client'
24
7
  require_relative 'http1/server'
@@ -1,24 +1,7 @@
1
1
  # frozen_string_literal: true
2
- #
3
- # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2017-2023, by Samuel Williams.
22
5
 
23
6
  require_relative 'http1'
24
7