Skip to content

Invalid WebTransport CONNECT returns Ok(WebTransportSession) after HTTP 400 #354

Description

@spotdemo4

Version

h3-webtransport 0.1.2

Platform

Linux desktop 7.1.7 NixOS x86_64 GNU/Linux

Summary

Invalid CONNECT returns a successful session object after sending HTTP 400

Code Sample

let request = http::Request::builder()
    .method(http::Method::POST) // or CONNECT without Protocol::WEB_TRANSPORT
    .uri("https://localhost/not-webtransport")
    .body(())?;

let result = WebTransportSession::accept(request, request_stream, h3_connection).await;

// Actual in 0.1.2: the peer receives HTTP 400, but the server gets Ok(session).
assert!(result.is_ok());

A complete harness needs an h3 request stream and peer settings with WebTransport and datagrams enabled so execution reaches the request validation branch.

Expected Behavior

Invalid input should produce a non-session outcome: an error, Ok(None), or an enum distinguishing accepted and rejected requests. Ok(WebTransportSession) should imply that a successful 2xx CONNECT response was sent.

Actual Behavior

WebTransportSession::accept() validates that the request is CONNECT with the WebTransport protocol extension. When validation fails, it sends an HTTP 400 Bad Request, but then continues constructing and returns Ok(WebTransportSession).

This allows application code to enter a session loop for a request the crate itself rejected on the wire.

Suggested upstream fix

Return immediately after sending the rejection response and expose a typed rejection result. Consolidate request validation ownership so callers do not need to duplicate the crate's private validation logic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions