mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
fix sending a header to the server more than once
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
@@ -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');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user