Skip to content

feat(http2): implement HTTP/2 server with TLS and h2c support#438

Merged
kcenon merged 6 commits into
mainfrom
feature/http2-server-implementation
Jan 13, 2026
Merged

feat(http2): implement HTTP/2 server with TLS and h2c support#438
kcenon merged 6 commits into
mainfrom
feature/http2-server-implementation

Conversation

@kcenon

@kcenon kcenon commented Jan 13, 2026

Copy link
Copy Markdown
Owner

Summary

  • Implement HTTP/2 server class with full protocol support (RFC 7540)
  • Add server-side stream handling for sending responses
  • Add request structure with pseudo-header parsing
  • Include comprehensive unit tests (28 tests) and sample code

Changes

New Files

  • include/kcenon/network/protocols/http2/http2_request.h - HTTP/2 request structure
  • include/kcenon/network/protocols/http2/http2_server.h - Server and connection classes
  • include/kcenon/network/protocols/http2/http2_server_stream.h - Response stream handling
  • src/protocols/http2/http2_server.cpp - Server implementation
  • src/protocols/http2/http2_server_stream.cpp - Stream implementation
  • tests/test_http2_server.cpp - Unit tests
  • samples/http2_server_example.cpp - Usage example

Features

  • HTTP/2 protocol support (RFC 7540) with HPACK header compression (RFC 7541)
  • TLS 1.3 with ALPN "h2" negotiation via start_tls()
  • Cleartext HTTP/2 (h2c) support via start()
  • Stream multiplexing with configurable max concurrent streams
  • Flow control with window update handling
  • Customizable HTTP/2 settings
  • Request handler callback for custom routing

Test Plan

  • All 28 unit tests pass
  • Build succeeds on local environment
  • Sample code compiles and runs
  • CI pipeline passes

Closes #406
Closes #433, #434, #435, #436, #437

…ling

Add http2_request struct to represent incoming HTTP/2 requests with:
- Pseudo-headers parsing (:method, :path, :scheme, :authority)
- Regular headers storage
- Helper methods for content-type, content-length
- Request body handling from DATA frames
- Validation for RFC 7540 compliance

Part of #406, closes #433
Implement http2_server_stream class providing server-side stream handling:
- Response headers with status code via HPACK encoding
- Data frame sending with automatic frame splitting
- Streaming response support (start_response, write, end_response)
- Stream reset functionality
- Flow control window management
- Thread-safe state management

Part of #406, closes #434
Add HTTP/2 server implementation with:
- http2_server: Main server class with TLS and non-TLS support
- http2_server_connection: Per-connection handler with frame processing
- Connection acceptance with ALPN "h2" negotiation
- SETTINGS exchange per RFC 7540
- Stream multiplexing support
- Flow control (connection and stream level)
- HPACK header compression/decompression
- Request handler callback API
- Cleanup timer for dead connections
- Proper GOAWAY handling on shutdown

Also updates CMakeLists.txt to include new source files.

Part of #406, closes #435
Add comprehensive tests for:
- http2_request: header parsing, content helpers, validation, from_headers
- http2_server: construction, settings, lifecycle, handlers
- http2_settings: default values
- tls_config: default values and property setting

All 28 tests passing.

Refs #406
Closes #436
Example demonstrates:
- Server creation and configuration
- HTTP/2 settings customization
- Request handler with routing
- Various endpoints (health check, echo, POST data)
- Graceful shutdown handling

The example uses h2c (HTTP/2 cleartext) for simplicity.
Production usage should use start_tls() with proper certificates.

Refs #406
Closes #437
- Add HTTP/2 server implementation entry to CHANGELOG.md
- Update FEATURES.md roadmap: HTTP/2 now complete
- Update planned enhancements to reference http2_server class

Refs #406
@github-actions

Copy link
Copy Markdown
Contributor

Performance Comparison

Base Branch Results

No base results

PR Branch Results

No PR results

@kcenon kcenon merged commit 0b9e970 into main Jan 13, 2026
44 checks passed
@kcenon kcenon deleted the feature/http2-server-implementation branch January 13, 2026 10:52
kcenon added a commit that referenced this pull request Apr 13, 2026
* feat(http2): add http2_request structure for server-side request handling

Add http2_request struct to represent incoming HTTP/2 requests with:
- Pseudo-headers parsing (:method, :path, :scheme, :authority)
- Regular headers storage
- Helper methods for content-type, content-length
- Request body handling from DATA frames
- Validation for RFC 7540 compliance

Part of #406, closes #433

* feat(http2): add http2_server_stream class for response handling

Implement http2_server_stream class providing server-side stream handling:
- Response headers with status code via HPACK encoding
- Data frame sending with automatic frame splitting
- Streaming response support (start_response, write, end_response)
- Stream reset functionality
- Flow control window management
- Thread-safe state management

Part of #406, closes #434

* feat(http2): implement http2_server class for HTTP/2 server support

Add HTTP/2 server implementation with:
- http2_server: Main server class with TLS and non-TLS support
- http2_server_connection: Per-connection handler with frame processing
- Connection acceptance with ALPN "h2" negotiation
- SETTINGS exchange per RFC 7540
- Stream multiplexing support
- Flow control (connection and stream level)
- HPACK header compression/decompression
- Request handler callback API
- Cleanup timer for dead connections
- Proper GOAWAY handling on shutdown

Also updates CMakeLists.txt to include new source files.

Part of #406, closes #435

* Add unit tests for HTTP/2 server implementation

Add comprehensive tests for:
- http2_request: header parsing, content helpers, validation, from_headers
- http2_server: construction, settings, lifecycle, handlers
- http2_settings: default values
- tls_config: default values and property setting

All 28 tests passing.

Refs #406
Closes #436

* Add HTTP/2 server example demonstrating basic usage

Example demonstrates:
- Server creation and configuration
- HTTP/2 settings customization
- Request handler with routing
- Various endpoints (health check, echo, POST data)
- Graceful shutdown handling

The example uses h2c (HTTP/2 cleartext) for simplicity.
Production usage should use start_tls() with proper certificates.

Refs #406
Closes #437

* Update documentation for HTTP/2 server implementation

- Add HTTP/2 server implementation entry to CHANGELOG.md
- Update FEATURES.md roadmap: HTTP/2 now complete
- Update planned enhancements to reference http2_server class

Refs #406
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.

[HTTP2] Implement http2_request structure [HTTP2] Implement HTTP/2 server-side support

1 participant