Skip to content

feat: H1 parser detects Upgrade: h2c + HTTP2-Settings headers #117

@FumingPower3925

Description

@FumingPower3925

Summary

Extend the H1 request parser to detect HTTP/2 Upgrade headers per RFC 7540 §3.2. The parser must identify when a client is requesting an h2c upgrade and extract the HTTP2-Settings payload.

RFC 7540 §3.2 Upgrade Request

GET / HTTP/1.1
Host: example.com
Connection: Upgrade, HTTP2-Settings
Upgrade: h2c
HTTP2-Settings: <base64url encoded SETTINGS payload>

All three conditions must be met:

  1. Upgrade: h2c header present
  2. HTTP2-Settings header present with base64url-encoded value
  3. Connection header includes both Upgrade and HTTP2-Settings tokens

Implementation

Files: protocol/h1/request.go, protocol/h1/parser.go

Add fields to h1.Request:

UpgradeH2C    bool   // true when valid h2c upgrade detected
HTTP2Settings string // raw base64url-encoded settings value

In appendHeader():

  • Case-insensitively detect upgrade header with value h2c
  • Case-insensitively detect http2-settings header, store value
  • Case-insensitively detect connection header, check for upgrade and http2-settings tokens
  • Set UpgradeH2C = true only when ALL three conditions are satisfied

In reset():

  • Clear both new fields

Acceptance Criteria

  • UpgradeH2C and HTTP2Settings fields on h1.Request
  • Detection logic in appendHeader() handles case-insensitive matching
  • Only sets UpgradeH2C = true when all three header conditions are met
  • reset() clears the new fields
  • Unit tests: valid upgrade, missing connection token, missing http2-settings, case variations

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions