File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed
lib/async/http/protocol/http1 Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change 33# Released under the MIT License.
44# Copyright, 2018-2023, by Samuel Williams.
55# Copyright, 2020, by Igor Sidorov.
6+ # Copyright, 2023, by Thomas Morgan.
67
78require_relative 'connection'
89
@@ -14,6 +15,9 @@ class Server < Connection
1415 def fail_request ( status )
1516 @persistent = false
1617 write_response ( @version , status , { } , nil )
18+ write_body ( @version , nil )
19+ rescue Errno ::ECONNRESET , Errno ::EPIPE
20+ # Handle when connection is already closed
1721 end
1822
1923 def next_request
Original file line number Diff line number Diff line change 33# Released under the MIT License.
44# Copyright, 2017-2023, by Samuel Williams.
55# Copyright, 2018, by Janko Marohnić.
6+ # Copyright, 2023, by Thomas Morgan.
67
78require 'async/http/protocol/http11'
89require_relative 'shared_examples'
910
1011RSpec . describe Async ::HTTP ::Protocol ::HTTP11 do
1112 it_behaves_like Async ::HTTP ::Protocol
1213
14+ context 'bad requests' do
15+ include_context Async ::HTTP ::Server
16+
17+ around do |example |
18+ current = Console . logger . level
19+ Console . logger . fatal!
20+
21+ example . run
22+ ensure
23+ Console . logger . level = current
24+ end
25+
26+ it "should fail cleanly when path is empty" do
27+ response = client . get ( "" )
28+
29+ expect ( response . status ) . to be == 400
30+ end
31+ end
32+
1333 context 'head request' do
1434 include_context Async ::HTTP ::Server
1535
You can’t perform that action at this time.
0 commit comments