tarampampam / webhook-tester

🔭 Powerful tool for testing WebHooks and more
MIT License
184 stars 30 forks source link

Cannot open PDF sent as multipart/form-data #307

Open hirenshah opened 1 year ago

hirenshah commented 1 year ago

I'm sending a PDF file as multipart/form-data and when I click download, for some reason it saves it as a .bin. The contents look like a PDF but also happen to have the following at the start:

--b4baaa6a-3ea0-4490-9026-e81849d841d2
Content-Type: application/pdf
Content-Disposition: form-data; name="document"; filename="01234567891011_Confirmation_Signed.pdf"; filename*=utf-8''01234567891011_Confirmation_Signed.pdf

And this at the end:

--b4baaa6a-3ea0-4490-9026-e81849d841d2--

Even after removing those parts, the PDF cannot be opened. File attached as a .txt because it wouldn't let me upload a .bin.

Am I missing something here?

3a8e6dfa-2c93-4f67-af74-dc485f091998.txt

hirenshah commented 1 year ago

Not sure if it helps, but this is what happens when the same request is sent to webhook.site:

image

tarampampam commented 1 year ago

I'm going to rewrite the UI completely, can you wait for that?

hirenshah commented 1 year ago

I'm going to rewrite the UI completely, can you wait for that?

Of course 🙂

I'm not paying for this so it would just be rude if I did anything other than wait.

Do you have a rough time line in mind? Give me a shout if you need help with testing 👍

tarampampam commented 1 year ago

Not yet, most part of my time is spent at my regular job..

hirenshah commented 1 year ago

Not yet, most part of my time is spent at my regular job..

That is fine. This one isn't a big issue for me because the PDF is only being sent here for testing purposes.

The other two issues I raised were more significant: https://github.com/tarampampam/webhook-tester/issues/306 https://github.com/tarampampam/webhook-tester/issues/308

I added comments to #308 as I spotted an issue with #306 and more with #308. If those could be fixed please, it would be much appreciated.

Also, can you drop me an email (my email address is visible in my profile) with details of how I can donate some £ for all your hard work 🙂

tarampampam commented 4 weeks ago

@hirenshah Great news - I’ve identified the reason why the downloaded file appeared broken. The issue was on the JS side, and in the v2 (which I’m actively working on), this will be resolved).

I expect to complete this in a few weeks, and I hope you’ll enjoy the new UI and new features ;)

Do not click here ![image](https://github.com/user-attachments/assets/467b31de-bad0-4ea5-8f4d-ee95679d07f1) ![image](https://github.com/user-attachments/assets/5e49b9fe-9c5b-4e93-af33-7448158dea3a)
tarampampam commented 3 weeks ago

Could you test the early v2 build to ensure everything works as expected now?

The Docker image and precompiled binary files are available at this link: https://github.com/tarampampam/webhook-tester/releases/tag/v2.0.0-alpha1

hirenshah commented 6 days ago

Running Alpha 4 and I posted a PNG using Postman. The download button writes all of the text you see to a file, which results in an invalid PNG. Removing first three lines and the last line fixes the file.

image

Ideally the filename value should be used when saving the file, as well as the boundary and content lines being removed.

It gets a little more complicated when multiple files and key/value pairs are posted as form-data. Each file would need to be saved separately, and text just ignored:

image

tarampampam commented 6 days ago

This is fine because the request body depends on what data you are sending and how you are sending it. For multipart requests, the server receiving the data determines how to interpret it. If you are only capturing the data being sent, you will need to handle it yourself. While this might seem a bit unusual, it can be very useful for debugging how the server constructs the multipart request