Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable XURL.Post from automatically setting the Headers #12

Open
nielsrietkerk opened this issue Jun 1, 2018 · 0 comments
Open

Disable XURL.Post from automatically setting the Headers #12

nielsrietkerk opened this issue Jun 1, 2018 · 0 comments
Assignees
Labels
Dwight enhancement New feature or request

Comments

@nielsrietkerk
Copy link

I'm currently working on a project for RecordPoint and I have to upload binaries to their API. The problem I encounter with the code below is that their API doesn't accept the Header Transfer-Encoding that is automatically set. I have asked them if they can solve this on their end but that could take a long time.

Example of XURL.post request
var result = XURL.post("https://httpbin.org/post", File.openRead("c:/Projects/test.docx"));

To solve this I tried to create the body myself to prevent XURL.post from setting the Transfer-Encoding header (see code below). This workaround failed because the Content-Length header was automatically set and was based on the Base64 string and not on the number of bytes of the original file.

Example of workaround
var file = File.openRead("c:/Projects/test.docx");
var body = "data:application/octet-stream;base64," :: Stream.getText(Encode.toBase64(file));
var result = XURL.post("https://httpbin.org/post", body);

All that said, it would be very helpfull if there is a way to disable XURL from automatically setting the headers to be more flexibel in these kind of situations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dwight enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants