Skip to content

Setting pseudo-headers for H2 request #2307

@kyrylodolynskyi

Description

@kyrylodolynskyi

Bug Description

I want to use undici with the allowH2 flag to overcome CloudFlare anti-DDoS behavior, this requires :method, :authority, :path, and :scheme pseudo-headers to be sent, but undici doesn't add them on its own (as browser does) and doesn't allow to set them by myself, since the header key validation from http1.1 is applied.

Reproducible By

import {fetch, Client} from 'undici'

const client = new Client(`<http2 server>`, {
  allowH2: true,
})

await fetch('<http2 resource>', {
  dispatcher: client,
  headers: {
    ':authority': '<authority>',
    ':method': 'GET',
    ':path': '<path>',
    ':scheme': 'https'
  }
})

Expected Behavior

The pseudo-headers are added by the fetch itself, or it is possible to pass them manually.

Environment

macOS Ventura 13.4.1, Node v20.5.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions