Mitmweb: Add initial support for browser fetch command export by skrattara · Pull Request #8060 · mitmproxy/mitmproxy
Description
This adds initial support for exporting or copying a request flow as a web browser fetch command. I've specified the command as browser because I might decide to add an export for Node.js's fetch API in the future as well.
This covers basic GET and POST requests with text content, and escapes whitespaces, double-quotes to ", Unicode characters to \uXXXX.
Closes #4408.
TODO:
- Investigate how this interacts with form data
- Investigate how this interacts with files and blobs
- Investigate how this interacts with binary content - throws error if outside the Unicode range, escapes it otherwise
- Investigate how this interacts with CORS - You can't, since the browser is the one that enforces CORS
- Investigate how this interacts with f-string/escaping trickery
Please add more tests.
Checklist
- I have updated tests where applicable.
- I have added an entry to the CHANGELOG.