Skip to content

Commit

Permalink
Check for upgrade header
Browse files Browse the repository at this point in the history
  • Loading branch information
jrothrock committed Mar 1, 2024
1 parent f113066 commit 57809b4
Showing 1 changed file with 2 additions and 4 deletions.
Expand Up @@ -4,8 +4,6 @@ class RequestQueueTimeConverter < ConverterBase

HEADERS = %w(X-Queue-Start X-Request-Start X-QUEUE-START X-REQUEST-START x-queue-start x-request-start)

WEBSOCKET_HEADERS = %w(SEC_WEBSOCKET_VERSION Sec-WebSocket-Version SEC_WEBSOCKET_PROTOCOL Sec-WebSocket-Protocol SEC_WEBSOCKET_KEY Sec-WebSocket-Key)

def headers
request.headers
end
Expand All @@ -17,7 +15,7 @@ def record!

return unless headers

# When an application uses TurboStreams, we capture very innaccurate queue times.
# When an application uses Turbo Streams, we capture very innaccurate queue times.
return if request_over_websocket?

raw_start = locate_timestamp
Expand All @@ -44,7 +42,7 @@ def record!
private

def request_over_websocket?
WEBSOCKET_HEADERS.any? { |header| headers[header] }
headers["Upgrade"] == "websocket"
end

# Looks through the possible headers with this data, and extracts the raw
Expand Down

0 comments on commit 57809b4

Please sign in to comment.