Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 14, 2025

Overview

This PR implements HTTP/2 protocol support for the dev proxy command, allowing developers to proxy HTTP/2 requests to backend servers.

Changes

Core Implementation

The proxy command now supports the --http2 flag to enable HTTP/2 protocol:

# Start an HTTP/2-enabled proxy server
$ dev proxy --port=12778 --target=12777 --http2

Key features:

  • HTTP/2 Protocol Support: Uses Node.js native http2 module to create a secure HTTP/2 server
  • Automatic SSL/TLS: HTTP/2 requires HTTPS, so SSL is automatically enabled (uses default certificates or custom ones via --ssl-cert and --ssl-key)
  • HTTP/1.1 Fallback: Server supports both HTTP/2 and HTTP/1.1 clients through allowHTTP1: true option
  • Header Filtering: Automatically filters connection-specific headers that are forbidden in HTTP/2 (connection, keep-alive, proxy-connection, transfer-encoding, upgrade)
  • Backward Compatible: All existing proxy modes (HTTP, HTTPS) continue to work unchanged

Implementation Details

The HTTP/2 implementation handles requests differently from HTTP/1.1:

  • Uses stream-based event handling for HTTP/2 requests
  • Extracts HTTP/2 pseudo-headers (:method, :path, :authority)
  • Converts headers to HTTP/1.1 format for backend communication
  • Filters response headers to comply with HTTP/2 specifications
  • Detects HTTP version to route HTTP/1.1 requests through the compatibility handler

Documentation

Updated README.md with:

  • HTTP/2 usage examples
  • Comprehensive parameter documentation
  • Examples for all proxy modes

Testing

Verified functionality with:

  • HTTP/2 client requests (using curl --http2)
  • HTTP/1.1 fallback (using curl --http1.1)
  • Regular HTTP and HTTPS proxy modes
  • Request logging and error handling

Usage

# HTTP/2 proxy
$ dev proxy --port=12778 --target=12777 --http2

# HTTP/2 with custom certificates
$ dev proxy --http2 --ssl-cert=path/to/cert.pem --ssl-key=path/to/key.pem --target=https://api.example.com

# Traditional modes still work
$ dev proxy --ssl --target=12777
$ dev proxy --target=https://www.example.com

Closes the issue requesting HTTP/2 support for the dev proxy command.

Original prompt

This section details on the original issue you should resolve

<issue_title>dev proxy support http2</issue_title>
<issue_description>
when the dev proxy command is execued with --http2 parameter, it initiate a ssl and http2-enabled server to act as a proxy that relays request to the backend</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #57


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: echosoar <14832743+echosoar@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for HTTP2 in dev proxy command Add HTTP/2 protocol support to dev proxy command Oct 14, 2025
Copilot AI requested a review from echosoar October 14, 2025 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dev proxy support http2

2 participants