[GH-ISSUE #1906] Multipart $http.post() in scripts #1898

Open
opened 2026-03-03 19:55:16 +03:00 by kerem · 6 comments
Owner

Originally created by @nihaals on GitHub (Jan 13, 2024).
Original GitHub issue: https://github.com/ProxymanApp/Proxyman/issues/1906

Originally assigned to: @NghiaTranUIT on GitHub.

Description

It would be great if there was a way to do a multipart/form-data request in scripts.

Why this feature/change is important?

If you need to call an API that requires multipart you need to add FormData polyfills which also might not interact with $http.post() correctly as the function itself isn't documented.

Originally created by @nihaals on GitHub (Jan 13, 2024). Original GitHub issue: https://github.com/ProxymanApp/Proxyman/issues/1906 Originally assigned to: @NghiaTranUIT on GitHub. ## Description It would be great if there was a way to do a `multipart/form-data` request in scripts. ## Why this feature/change is important? If you need to call an API that requires `multipart` you need to add `FormData` polyfills which also might not interact with `$http.post()` correctly as the function itself isn't documented.
Author
Owner

@NghiaTranUIT commented on GitHub (Jan 14, 2024):

You're right @nihaals , the Scriprint tool doesn't support the FormData or multipart. The problem is JavascriptCore framework (from Apple) doesn't support axios, fetch, or URLSearchParam, or FormData.

I'm thinking if I can replace our custom $http with whatwg-fetch (https://www.npmjs.com/package/whatwg-fetch) to the Scripting, so it can work with FormData and other type of body.

<!-- gh-comment-id:1890830880 --> @NghiaTranUIT commented on GitHub (Jan 14, 2024): You're right @nihaals , the Scriprint tool doesn't support the FormData or `multipart`. The problem is JavascriptCore framework (from Apple) doesn't support axios, fetch, or URLSearchParam, or FormData. I'm thinking if I can replace our custom `$http` with `whatwg-fetch` (https://www.npmjs.com/package/whatwg-fetch) to the Scripting, so it can work with FormData and other type of body.
Author
Owner

@nihaals commented on GitHub (Jan 14, 2024):

Being able to point to exactly what Proxyman uses sounds quite helpful as it would reduce the need for as thorough documentation on $http and especially if it's based on fetch(), its usage will be fairly intuitive and similar to JS people have already written. I also think trying to make Proxyman match a typical JS environment as much as possible makes it feel less like "it's JS syntax but a custom environment" and more like "it's just JS" (which documenting the environment scripts run in would also help with so users can dive into more docs if needed and search for workarounds).

<!-- gh-comment-id:1890834180 --> @nihaals commented on GitHub (Jan 14, 2024): Being able to point to exactly what Proxyman uses sounds quite helpful as it would reduce the need for as thorough documentation on `$http` and especially if it's based on `fetch()`, its usage will be fairly intuitive and similar to JS people have already written. I also think trying to make Proxyman match a typical JS environment as much as possible makes it feel less like "it's JS syntax but a custom environment" and more like "it's just JS" (which documenting the environment scripts run in would also help with so users can dive into more docs if needed and search for workarounds).
Author
Owner

@NghiaTranUIT commented on GitHub (Jan 15, 2024):

@nihaals It's so difficult to support native fetch because XMLHTTPRequest doesn't support in JavascriptCore too.

Even with React-native-fetch, they also develop their own custom XMLHTTPRequest with a lot of react-native logic. Tried to bring to Proxyman, but no luck 😢

The same thing with axios, or superagent too, it's built on top of XMLHTTPRequest

<!-- gh-comment-id:1892024033 --> @NghiaTranUIT commented on GitHub (Jan 15, 2024): @nihaals It's so difficult to support native `fetch` because `XMLHTTPRequest` doesn't support in JavascriptCore too. Even with [React-native-fetch](https://github.com/react-native-community/fetch), they also develop their own custom `XMLHTTPRequest` with a lot of react-native logic. Tried to bring to Proxyman, but no luck 😢 The same thing with axios, or superagent too, it's built on top of `XMLHTTPRequest`
Author
Owner

@nihaals commented on GitHub (Jan 17, 2024):

I guess you'd basically need to do something like https://github.com/Lukas-Stuehrk/XMLHTTPRequest? I have no idea how much work that is but I guess one advantage would be that if it passes tests you wouldn't have to mess with $http much again?

<!-- gh-comment-id:1894781432 --> @nihaals commented on GitHub (Jan 17, 2024): I guess you'd basically need to do something like https://github.com/Lukas-Stuehrk/XMLHTTPRequest? I have no idea how much work that is but I guess one advantage would be that if it passes tests you wouldn't have to mess with `$http` much again?
Author
Owner

@NghiaTranUIT commented on GitHub (Jan 17, 2024):

I tried, but it didn't work. The fetch-polyfill recognizes the XMLHttpRequest, but it stuck when making a request.

I guess this library is obsoleted (the last update was 7 years ago), and it only handles the Text-based Response body (https://github.com/Lukas-Stuehrk/XMLHTTPRequest/issues/1)

<!-- gh-comment-id:1894799046 --> @NghiaTranUIT commented on GitHub (Jan 17, 2024): I tried, but it didn't work. The `fetch-polyfill` recognizes the XMLHttpRequest, but it stuck when making a request. I guess this library is obsoleted (the last update was 7 years ago), and it only handles the Text-based Response body (https://github.com/Lukas-Stuehrk/XMLHTTPRequest/issues/1)
Author
Owner

@nihaals commented on GitHub (Jan 17, 2024):

Maybe a simpler solution would be adding FormData and supporting $http.post({body: FormData})?

<!-- gh-comment-id:1894816269 --> @nihaals commented on GitHub (Jan 17, 2024): Maybe a simpler solution would be adding `FormData` and supporting `$http.post({body: FormData})`?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/Proxyman#1898
No description provided.