fizzstudio / nanotation

Prototype Chrome extension to enable "deep link" sharing of a selection, with anyone else who has this extension. Now being developed by Fizz Studio.
MIT License
9 stars 1 forks source link

"414 – URI too long error" #8

Open shepazu opened 6 years ago

shepazu commented 6 years ago

Reported by Adrian Roselli (@aardrian) on Twitter:

This is awesome. Sadly, I am getting a 414 (URI too long) error with this, my first one: http://adrianroselli.com/2017/11/os-high-contrast-versus-inverted-colors.html?text=If%2520a%2520page%2520already%2520has%2520poor%2520contrast%252C%2520this%2520does%2520not%2520increase%2520the%2520contrast&note=This%2520is%2520why%2520any%2520%25E2%2580%2598invert%2520color%25E2%2580%2599%2520mode%2520is%2520not%2520a%2520panacea.#Skip … Only 340 chars.

shepazu commented 6 years ago

Here are some HTTP Error 414 Request URI too long references:

Pragmatically, best practice seems to indicate that we should keep URLS to fewer than 2048 characters, both for servers and for (older) browsers. Consider adding a length warning.

In this case, Adrian's URL was blocked at only 340 characters, either by the server or by the blog software. Manual testing showed that his server's limit seems to be 280 characters. Maybe that is a common blocking point that should be given a warning?

Another possible solution is to actually test the URL in the extension, send a curl test to see if the page gives an HTTP error, then warn the user about that particular server's limits and suggest a shorter selection and/or note.

shepazu commented 6 years ago

Version 0.4.5 somewhat addresses this issue by switching to using only native URLSearchParams encoding, which uses + instead of %20, resulting in ~40% smaller query strings, more stability, easier maintenance, and better URL readability.

Compare:

aardrian commented 6 years ago

Can confirm that the sample URL works now (the shorter / new URL). After I updated the extension, of course.