Skip to content

alt-svc: a percent-encoded protocol-id (http%2F1.1) is not recognised, while the unencoded http/1.1 is #23654

Closed

Description

@ahzf

I did this

A server sends, over HTTPS:

Alt-Svc: http%2F1.1=":8443"; ma=60

and curl is run with --alt-svc cache.txt. curl writes the cache file, but it contains no entry.

RFC 7838 §3 defines protocol-id = token ; percent-encoded ALPN protocol name and says "Octets not allowed in tokens […] MUST be percent-encoded". / is not a tchar, so http%2F1.1 is the only conforming way to name http/1.1.

Measured with curl 8.21.0 (x86_64-w64-mingw32, Schannel) and 8.14.1 (x86_64-pc-linux-gnu, OpenSSL), with the server sending one value at a time:

Alt-Svc sent recorded
h2=":8443" h2
h3=":8443" h3
h1=":8443" h1
http/1.1=":8443" (not a token) h1
http%2F1.1=":8443" nothing

Curl_altsvc_parse (lib/altsvc.c) passes the text before = unchanged to Curl_alpn2alpnid (lib/connect.c). That function compares it with the literals h1, h2, h3 and http/1.1. So the conforming spelling is skipped as an unknown protocol, and the non-conforming one is accepted. Current master looks the same.

I expected the following

curl percent-decodes the protocol-id before mapping it, so http%2F1.1 is recorded as h1.

curl/libcurl version

8.21.0 and 8.14.1, code read on master 2026-10-28

operating system

Windows 11, Debian 13 (WSL)

Activity

  1. added a commit that references this issue on Oct 28, 2026
  2. icing commented on Oct 28, 2026

    @icing
    Contributor

    Every day you learn something new. RFC 7838, Section 3 indeed defines the "protocol-id" as "percent encoded ALPN protocol name".

    So, your server is not incorrect. Just surprising.

  3. added 3 commits that reference this issue on Oct 28, 2026
    b172124
    abccab6
    9e8853c
  4. jay commented on Oct 28, 2026

    @jay
    Member

    RFC 7838, Section 3 indeed defines the "protocol-id" as "percent encoded ALPN protocol name".

    interesting. also the hex must be uppercase, for comparison purposes i assume

       In order to have precisely one way to represent any ALPN protocol
       name, the following additional constraints apply:
    
       1.  Octets in the ALPN protocol name MUST NOT be percent-encoded if
           they are valid token characters except "%", and
    
       2.  When using percent-encoding, uppercase hex digits MUST be used.
    
  5. added 2 commits that reference this issue on Oct 29, 2026
    a33e22f
    69ad3df
  6. added a commit that references this issue on Oct 29, 2026
    a4eed8c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions