mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
chore: fixup redirect in bidi/core
(#11879)
This commit is contained in:
parent
bfcd65d2f7
commit
59c4daa5ee
@ -66,10 +66,11 @@ export class Request extends EventEmitter<{
|
|||||||
new EventEmitter(this.#session)
|
new EventEmitter(this.#session)
|
||||||
);
|
);
|
||||||
sessionEmitter.on('network.beforeRequestSent', event => {
|
sessionEmitter.on('network.beforeRequestSent', event => {
|
||||||
if (event.context !== this.#browsingContext.id) {
|
if (
|
||||||
return;
|
event.context !== this.#browsingContext.id ||
|
||||||
}
|
event.request.request !== this.id ||
|
||||||
if (event.request.request !== this.id) {
|
this.#redirect !== undefined
|
||||||
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.#redirect = Request.from(this.#browsingContext, event);
|
this.#redirect = Request.from(this.#browsingContext, event);
|
||||||
@ -77,10 +78,10 @@ export class Request extends EventEmitter<{
|
|||||||
this.dispose();
|
this.dispose();
|
||||||
});
|
});
|
||||||
sessionEmitter.on('network.fetchError', event => {
|
sessionEmitter.on('network.fetchError', event => {
|
||||||
if (event.context !== this.#browsingContext.id) {
|
if (
|
||||||
return;
|
event.context !== this.#browsingContext.id ||
|
||||||
}
|
event.request.request !== this.id
|
||||||
if (event.request.request !== this.id) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.#error = event.errorText;
|
this.#error = event.errorText;
|
||||||
@ -88,14 +89,18 @@ export class Request extends EventEmitter<{
|
|||||||
this.dispose();
|
this.dispose();
|
||||||
});
|
});
|
||||||
sessionEmitter.on('network.responseCompleted', event => {
|
sessionEmitter.on('network.responseCompleted', event => {
|
||||||
if (event.context !== this.#browsingContext.id) {
|
if (
|
||||||
return;
|
event.context !== this.#browsingContext.id ||
|
||||||
}
|
event.request.request !== this.id
|
||||||
if (event.request.request !== this.id) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.#response = event.response;
|
this.#response = event.response;
|
||||||
this.emit('success', this.#response);
|
this.emit('success', this.#response);
|
||||||
|
// In case this is a redirect.
|
||||||
|
if (this.#response.status >= 300 && this.#response.status < 400) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.dispose();
|
this.dispose();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -126,7 +131,7 @@ export class Request extends EventEmitter<{
|
|||||||
return this.#event.navigation ?? undefined;
|
return this.#event.navigation ?? undefined;
|
||||||
}
|
}
|
||||||
get redirect(): Request | undefined {
|
get redirect(): Request | undefined {
|
||||||
return this.redirect;
|
return this.#redirect;
|
||||||
}
|
}
|
||||||
get response(): Bidi.Network.ResponseData | undefined {
|
get response(): Bidi.Network.ResponseData | undefined {
|
||||||
return this.#response;
|
return this.#response;
|
||||||
|
Loading…
Reference in New Issue
Block a user