-
-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [1502] Allow fetch to be intercepted and modified
- Loading branch information
Showing
6 changed files
with
148 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
packages/happy-dom/src/fetch/types/IAsyncRequestInterceptor.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import Request from '../Request.js'; | ||
import BrowserWindow from '../../window/BrowserWindow.js'; | ||
import Response from '../Response.js'; | ||
|
||
export default interface IAsyncRequestInterceptor { | ||
/** | ||
* Hook dispatched before sending out async fetches. | ||
* It can be used for modifying the request, providing a response without making a request or for logging. | ||
* | ||
* @param request The request about to be sent out. | ||
* @param window The window from where the request originates. | ||
* | ||
* @returns Promise that can resolve to a response to be used instead of sending out the response. | ||
*/ | ||
beforeSend?: (request: Request, window: BrowserWindow) => Promise<Response | void>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters