mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
## Summary Fixes a bug where sequential HTTP requests with proxy-style absolute URLs (e.g. `GET http://example.com/path HTTP/1.1`) hang on the 2nd+ request when using keep-alive connections. ## Root Cause In `packages/bun-uws/src/HttpParser.h`, the parser was treating proxy-style absolute URLs identically to `CONNECT` method requests — setting `isConnectRequest = true` and entering tunnel mode. This flag was never reset between requests on the same keep-alive connection, so the 2nd+ request was swallowed as raw tunnel data instead of being parsed as HTTP. ## Fix 3-line change in `HttpParser.h:569`: - **`isConnect`**: Now only matches actual `CONNECT` method requests (removed `isHTTPorHTTPSPrefixForProxies` from the condition) - **`isProxyStyleURL`**: New variable that detects `http://`/`https://` prefixes and accepts them as valid request targets — without triggering tunnel mode ## Who was affected - Any Bun HTTP server (`Bun.serve()` or `node:http createServer`) receiving proxy-style requests on keep-alive connections - HTTP proxy servers built with Bun could only handle one request per connection - Bun's own HTTP client making sequential requests through an HTTP proxy backed by a Bun server ## Test Added `test/js/node/http/node-http-proxy-url.test.ts` with 3 test cases: 1. Sequential GET requests with absolute URL paths 2. Sequential POST requests with absolute URL paths 3. Mixed normal and proxy-style URLs Tests run under both Node.js and Bun for compatibility verification. - ❌ Fails with system bun (2/3 tests timeout on 2nd request) - ✅ Passes with debug build (3/3 tests pass) --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
27 lines
851 B
TypeScript
27 lines
851 B
TypeScript
import { describe, expect, test } from "bun:test";
|
|
import { bunEnv, bunExe, nodeExe } from "harness";
|
|
import { join } from "node:path";
|
|
|
|
describe("HTTP server with proxy-style absolute URLs", () => {
|
|
test("tests should run on node.js", async () => {
|
|
await using process = Bun.spawn({
|
|
cmd: [nodeExe(), "--test", join(import.meta.dir, "node-http-proxy-url.node.mts")],
|
|
stdout: "inherit",
|
|
stderr: "inherit",
|
|
stdin: "ignore",
|
|
env: bunEnv,
|
|
});
|
|
expect(await process.exited).toBe(0);
|
|
});
|
|
test("tests should run on bun", async () => {
|
|
await using process = Bun.spawn({
|
|
cmd: [bunExe(), "test", join(import.meta.dir, "node-http-proxy-url.node.mts")],
|
|
stdout: "inherit",
|
|
stderr: "inherit",
|
|
stdin: "ignore",
|
|
env: bunEnv,
|
|
});
|
|
expect(await process.exited).toBe(0);
|
|
});
|
|
});
|