puppeteer-sharp icon indicating copy to clipboard operation
puppeteer-sharp copied to clipboard

Allow customization of fetch patterns

Open syscafedevelopment opened this issue 6 years ago • 10 comments

Customization of fetch patterns including specifying the RequestStage and ResourceType

syscafedevelopment avatar Jun 22 '19 12:06 syscafedevelopment

Hey @syscafedevelopment. Could you tell me a real use case scenario? So I can try to propose this upstream (a.k.a puppeteer).

kblok avatar Jun 24 '19 11:06 kblok

We would also need some tests for this.

And by the way. Thank you for your time contributing :)

kblok avatar Jun 24 '19 11:06 kblok

Hey @kblok,

A scenario would be:

  • the dev wants to download a certain resource (e.g., a video, a pdf, etc.)
  • when the request interception is made, the dev will need to call Chrome's Fetch.getResponseBody or Fetch.takeResponseBodyAsStream
  • however, this will require the interception to happen at HeadersReceived stage
  • additionally, the dev only needs to intercept those specific resource types, having predefined URL patterns
  • at the moment, all interceptions are at Request stage, with a hardcoded pattern of "*", which does not allow response body interceptions, nor selective interceptions

Apparently there are several complains and complicated workarounds about allowing downloading things via Puppeteer, which would start to be solved by customizing the interception stage first.

About unit tests, I'll handle those as soon as possible.

syscafedevelopment avatar Jun 24 '19 12:06 syscafedevelopment

@kblok, any idea why this is failing AppVeyor? It seems it needs Mono.Posix assembly? Why?

syscafedevelopment avatar Jul 13 '19 16:07 syscafedevelopment

@syscafedevelopment it seems that ShouldEmitCreatedAndDestroyedEvents is getting stuck...

On the other hand, I like this feature, but I'm waiting for Puppeteer's feedback here https://github.com/GoogleChrome/puppeteer/issues/4624. I don't want us to implement a feature and then they implement the same feature in a different way and we would be forced to change our API.

kblok avatar Jul 13 '19 16:07 kblok

@syscafedevelopment could you share your case here https://github.com/GoogleChrome/puppeteer/issues/4624 ?

kblok avatar Jul 15 '19 10:07 kblok

@kblok @syscafedevelopment Is this planned to be merged soon please?

emiliavanderwerf avatar Feb 25 '21 16:02 emiliavanderwerf

@emiliavanderwerf I could try to push a little bit upstream to see if we get this implemented in puppeteer.

kblok avatar Feb 25 '21 17:02 kblok

@kblok Ah, so not even Puppeteer implements this yet?

emiliavanderwerf avatar Feb 25 '21 17:02 emiliavanderwerf

@emiliavanderwerf exactly.

kblok avatar Feb 25 '21 17:02 kblok