AVATEAM-IT-SYSTEMHAUS / mkdocs-kroki-plugin

MkDocs plugin for Kroki-Diagrams
MIT License
42 stars 27 forks source link

414 Request-URI Too Large: Switch to POST if the URI is too long #2

Closed rumbin closed 2 years ago

rumbin commented 2 years ago

Problem Description

When an (excalidraw) drawing is too large (contains too many characters), then the URI becomes too large. This results in the image not being renderd in MkDocs. Instead, a placeholder image is shown:

image

I suppose that this is caused by the drawing code being too long. At least that is what https://kroki.io/#try shows when providing a too long excalidraw JSON.

Possible solution:

Switch to POST, either always or only if the URI would become too long. For reference, see identical issues of other languages and their solutions:

rumbin commented 2 years ago

POST is documented here: https://docs.kroki.io/kroki/setup/usage/

b-bittner commented 2 years ago

Thanks for this issue, it is a good idea to use this config parameter. I will try to implement it, but it could take some time. PRs are generally welcome

oniboni commented 2 years ago

@rumbin Can you provide some test data to reproduce the issue?

saheljalal commented 2 years ago

Any complicated or large export from excalidraw.com should work. Facing this as well, would be great if it could be switched to POST.

b-bittner commented 2 years ago

I just looked into this issue, but as far as I can see, there is other basic problem with that. At the moment, default configuration is to embed the drawings in an html img tag with the URL as source. It seems so, that Image-Tags in html can only have GET-Requests as source (Am I correct?).

If so, I only see the option to first download the drawing (which is optional at the moment). So a solution could be:

Feedback please!

saheljalal commented 2 years ago

Not sure I fully understand the image tag reference and I have limited Python knowledge, but looking at the plugin code, it seems that it is using urlretrieve which by default uses GET.

Maybe there is another way to implement this using the standard library by passing in data and making it use POST instead. Also, any reason to not just always use POST?

oniboni commented 2 years ago

@b-bittner Yes, you are right. Your solution would work as a quick fix.

I looked into the asciidoc plugin and it seems, that they are doing the request via JS in the browser at a later stage. This may also be an option.

b-bittner commented 2 years ago

This issue should now be fixed with #7