Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/pitchfork/http_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ def read(socket)
e['pitchfork.socket'] = socket
e['rack.hijack'] = self

# We don't support connection upgrade:
e.delete('HTTP_UPGRADE')

e.merge!(DEFAULTS)
end

Expand Down
24 changes: 24 additions & 0 deletions test/integration/test_http_basic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,28 @@ def test_write_on_close

assert_clean_shutdown(pid)
end

def test_http_upgrade
addr, port = unused_port

pid = spawn_server(app: File.join(ROOT, "test/integration/upgrade.ru"), config: <<~CONFIG)
listen "#{addr}:#{port}"
worker_processes 1
CONFIG

assert_healthy("http://#{addr}:#{port}")

Net::HTTP.start(addr, port) do |http|
request = Net::HTTP::Get.new("/")
request["Connection"] = "Upgrade"
request["Upgrade"] = "websocket"

# It should not be connection upgrade:
response = http.request(request)
assert_equal "200", response.code
assert_equal "Normal response", response.body
end

assert_clean_shutdown(pid)
end
end
8 changes: 8 additions & 0 deletions test/integration/upgrade.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# frozen_string_literal: true
run lambda { |env|
if env['HTTP_UPGRADE']
[404, {}, ["Upgrade not supported"]]
else
[200, {}, ["Normal response"]]
end
}