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

Ability to post data when using chromium #489

Open
davideapvd opened this issue Aug 29, 2022 · 4 comments
Open

Ability to post data when using chromium #489

davideapvd opened this issue Aug 29, 2022 · 4 comments
Labels
chromium enhancement New feature or request maybe

Comments

@davideapvd
Copy link

Is it be possible to change the request method to POST passing additional body data when using chromium engine?

@gulien
Copy link
Collaborator

gulien commented Aug 29, 2022

From the README.md:

You may use any HTTP client that is able to handle a PSR-7 RequestInterface to call the API:

use Gotenberg\Gotenberg;

$request = Gotenberg::chromium('http://localhost:3000')->url('https://my.url');

@davideapvd
Copy link
Author

Hello @gulien, what I meant is not for calling the api but instructing chromium to make a POST request to url, passing additional data (for example as multipart/form-data), instead, can you make an example if that's already possible?

@gulien
Copy link
Collaborator

gulien commented Aug 29, 2022

Ok, got it!

No, you can't do that, but you could try some workarounds, for instance by injecting a remote script that do the job (extraScriptTags - https://gotenberg.dev/docs/modules/chromium#url). I guess it would require the --chromium-disable-web-security property. Also, it would depend on the security backend wise.

If you have access to the URL source code, using custom HTTP headers might also do the trick:

curl \
--request POST 'http://localhost:3000/forms/chromium/convert/url' \
--form 'url="https://my.url"' \
--form 'userAgent="Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1"' \
--form 'extraHttpHeaders="{\"MyHeader\": \"MyValue\"}"' \
-o my.pdf

@davideapvd
Copy link
Author

I was thinking of using extraScriptTags but in the end is not really feasible, as I see, and speaking for a general case, it it could be useful to have a standard way to pass configuration data, because often those pdf are something we customize for a client: invoices, product configuration, reports, and are the result of some sort of form submit from the user.

I don't like the the suggested http header because often proxies are configured to have a really short http header limit and could be equivalent to passing GET data in terms on limitations.

What do you think?

@gulien gulien transferred this issue from gotenberg/gotenberg-php Aug 30, 2022
@gulien gulien added enhancement New feature or request chromium maybe labels Aug 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chromium enhancement New feature or request maybe
Projects
None yet
Development

No branches or pull requests

2 participants