fix sending a header to the server more than once

This commit is contained in:
Meghan Denny
2025-11-22 17:20:50 -08:00
parent 9768af14a9
commit 4875387ea4
3 changed files with 15 additions and 4 deletions

View File

@@ -155,10 +155,12 @@ static void assignHeadersFromUWebSocketsForCall(uWS::HttpRequest* request, JSVal
HTTPHeaderIdentifiers& identifiers = WebCore::clientData(vm)->httpHeaderIdentifiers();
Identifier nameIdentifier;
JSString* nameString = nullptr;
bool headerIsWellKnown = false;
if (WebCore::findHTTPHeaderName(nameView, name)) {
nameString = identifiers.stringFor(globalObject, name);
nameIdentifier = identifiers.identifierFor(vm, name);
headerIsWellKnown = true;
} else {
WTF::String wtfString = nameView.toString();
nameString = jsString(vm, wtfString);
@@ -177,13 +179,24 @@ static void assignHeadersFromUWebSocketsForCall(uWS::HttpRequest* request, JSVal
arrayValues.append(jsValue);
setCookiesHeaderArray->push(globalObject, jsValue);
RETURN_IF_EXCEPTION(scope, void());
} else {
if (headersObject->hasOwnProperty(globalObject, nameIdentifier)) {
if (headerIsWellKnown && name == HTTPHeaderName::Host) {
continue;
}
auto prev = headersObject->get(globalObject, nameIdentifier);
RETURN_IF_EXCEPTION(scope, );
auto thenew = jsString(vm, makeString(prev.getString(globalObject), ", "_s, jsValue));
headersObject->putDirectMayBeIndex(globalObject, nameIdentifier, thenew);
RETURN_IF_EXCEPTION(scope, );
arrayValues.append(nameString);
arrayValues.append(jsValue);
continue;
}
headersObject->putDirectMayBeIndex(globalObject, nameIdentifier, jsValue);
RETURN_IF_EXCEPTION(scope, void());
arrayValues.append(nameString);
arrayValues.append(jsValue);
RETURN_IF_EXCEPTION(scope, void());
}
}

View File

@@ -3,7 +3,6 @@ import { once } from "node:events";
import http from "node:http";
import type { AddressInfo } from "node:net";
const { expect } = createTest(import.meta.path);
if ("Bun" in globalThis) process.exit(0); // TODO: BUN
const { promise, resolve } = Promise.withResolvers();
await using server = http.createServer((req, res) => {

View File

@@ -25,7 +25,6 @@
// that support it, and dropping duplicates for other fields.
require('../common');
if ('Bun' in globalThis) return; // TODO: BUN
const assert = require('assert');
const http = require('http');