node-formidable / formidable

The most used, flexible, fast and streaming parser for multipart form data. Supports uploading to serverless environments, AWS S3, Azure, GCP or the filesystem. Used in production.
MIT License
7.04k stars 682 forks source link

HTTP2 ClientHttp2Stream support #891

Open FStefanni opened 1 year ago

FStefanni commented 1 year ago

Support plan

Context

What problem are you trying to solve?

Hi,

I am using formidable with Typescript. I have seen that the formidable.parse() method accepts http.IncomingMessage, which is fine for server side, and for HTTP1 client-side. But client-side with HTTP2, it should also accept http2.ClientHttp2Stream.

So the questions/issues are:

  1. Can formidable work with also http2.ClientHttp2Stream? I suppose so, but the Typescript compiler complains... (before putting a brutal unsafe cast I want to be sure)
  2. If not, it would be nice to also support this use case
  3. Types definitions should be updated accordingly (also if already supported)

Regards

EDIT

Just seen that also http2.Http2ServerRequest makes the Typescript compiler complain. So even HTTP2 seems not explicitly supported. So definitely supporting HTTP2 would be a useful feature.

Do you have a new or modified API suggestion to solve the problem?

If as I suppose, formidable already supports the HTTP2 client side, the problem fix is just a matter of updating the types definitions of formidable.parse() to accept also a http2.ClientHttp2Stream (http.IncomingMessage | http2.ClientHttp2Stream).

GrosSacASac commented 1 year ago

Thanks

nagayev commented 1 year ago

Thank you

tunnckoCore commented 1 year ago

@FStefanni I think it is supported too. We don't do much with the stream, we just get the headers - at least that's the very basic explanation of what Formidable is doing, haha. I guess it's the typings.

FStefanni commented 1 year ago

Hi,

yes I also suppose (but I have not done a deep dive in the code) that its only a matter of typings. So updating the types definitions could suffice and fix this issue.

Regards