Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
17 changes: 14 additions & 3 deletions src/base/http/http_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,20 @@ size_t HttpServer::ParseOneHttpRequest(HttpServerConnection* conn) {
if (IsOriginAllowed(hdr_value))
conn->origin_allowed_ = hdr_value.ToStdString();
} else if (hdr_name.CaseInsensitiveEq("connection")) {
conn->keepalive_ = hdr_value.CaseInsensitiveEq("keep-alive");
http_req.is_websocket_handshake =
hdr_value.CaseInsensitiveEq("upgrade");
size_t semicolon = hdr_value.find(',');
if (semicolon == StringView::npos) {
conn->keepalive_ = hdr_value.CaseInsensitiveEq("keep-alive");
http_req.is_websocket_handshake =
hdr_value.CaseInsensitiveEq("upgrade");
} else {
auto first = hdr_value.substr(0, semicolon);
auto second = hdr_value.substr(semicolon + 2);
http_req.is_websocket_handshake =
first.CaseInsensitiveEq("upgrade") ||
second.CaseInsensitiveEq("upgrade");
conn->keepalive_ = first.CaseInsensitiveEq("keep-alive") ||
second.CaseInsensitiveEq("keep-alive");
}
}
}
}
Expand Down
22 changes: 17 additions & 5 deletions ui/src/trace_processor/http_rpc_engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export class HttpRpcEngine extends EngineBase {
private websocket?: WebSocket;
private connected = false;
private disposed = false;
private queue: Blob[] = [];
private isProcessing = false;

// Can be changed by frontend/index.ts when passing ?rpc_port=1234 .
static rpcPort = '9001';
Expand Down Expand Up @@ -86,11 +88,21 @@ export class HttpRpcEngine extends EngineBase {
}

private onWebsocketMessage(e: MessageEvent) {
assertExists(e.data as Blob)
.arrayBuffer()
.then((buf) => {
super.onRpcResponseBytes(new Uint8Array(buf));
});
const blob = assertExists(e.data as Blob);
this.queue.push(blob);
this.processQueue();
}

private async processQueue() {
if (this.isProcessing) return;
this.isProcessing = true;
while (this.queue.length > 0) {
const blob = this.queue.shift();
if (!blob) continue;
const buf = await blob.arrayBuffer();
super.onRpcResponseBytes(new Uint8Array(buf));
}
this.isProcessing = false;
}

static async checkConnection(): Promise<HttpRpcState> {
Expand Down