Skip to content

Commit

Permalink
Merge pull request #135 from d-exclaimation/acception-combined-protocols
Browse files Browse the repository at this point in the history
fix: Allow combined protocol with , in headers
  • Loading branch information
d-exclaimation authored Jun 21, 2023
2 parents ca7d455 + 2a217fb commit c0556ff
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Sources/Pioneer/Vapor/WebSocket/Pioneer+WebSocket.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ public extension Pioneer {
func webSocketHandler(req: Request, context: @escaping VaporWebSocketContext, guard: @escaping VaporWebSocketGuard) async throws -> Response {
/// Explicitly handle Websocket upgrade with sub-protocol
let protocolHeader: [String] = req.headers[.secWebSocketProtocol]
.flatMap { $0.split(separator: ",") }
.map { String($0) }
.map { $0.trimmingCharacters(in: .whitespaces) }

guard let _ = protocolHeader.first(where: websocketProtocol.isValid) else {
return try GraphQLError(
message: "Unrecognized websocket protocol. Specify the 'sec-websocket-protocol' header with '\(websocketProtocol.name)'"
Expand Down

0 comments on commit c0556ff

Please sign in to comment.