Skip to content

How to stream headers with undici.stream? #2919

Answered by wlinna
wlinna asked this question in Q&A
Discussion options

You must be logged in to vote

From here it seems you are not attaching the headers to your undici.stream call.

Now I see how blind I've been. Example 1 shows that factory receives headers parameter that I can use to add the headers to the stream.

This is what my relevant code (TypeScript) looks like now, and it seems to work

            undici.stream(addr, {
                method: 'GET',
                opaque: res
            }, ({ headers, opaque }) => {
                const raw = (<any>opaque).raw;
                if (headers) {
                    for (const key in headers) {
                        const val = headers[key];
                        if (val) {
                            raw.appendHeader(key, v…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@wlinna
Comment options

Answer selected by wlinna
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants