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

Hrana URL strings: don't append pipeline/cursor routes blindly #919

Merged
merged 1 commit into from
Jan 23, 2024

Conversation

Horusiath
Copy link
Contributor

Atm. Hrana connection takes in a base_url and internally constructs a pipeline (/v3/pipeline) and cursor (/v3/cursor) URLs out of it. The thing is that it did so without properly checking if it's ok to do so. Therefore if someone set a base URL to ie. libsql://pen.turso.io/?authToken= it wouldn't immediately fail, but instead the requests would be send to an invalid endpoint (/?authToken=/v3/cursor instead of /v3/cursor/?authToken=). This PR changes that behaviour.

Now, we could think: why not use native URL parsing capabilities and use Url all the way down:

  1. Hyper and Cloudflare use different parsing libraries. Hyper uses http based one which comes with dependencies that we don't want on Cloudflare end.
  2. Cloudflare (and url crate, which it uses internally) comes with some limitations ie. url.set_scheme (which we need for things like switching libsqlhttps) explicitly disallows switching schemes of specific kinds, our use case included. Moreover it doesn't provide API to override that behaviour. Btw. url crate is the most popular Rust crate used for this purpose.

@Horusiath Horusiath added this pull request to the merge queue Jan 23, 2024
Merged via the queue into tursodatabase:main with commit d023667 Jan 23, 2024
12 checks passed
@Horusiath Horusiath deleted the libsql-base-url-parsing branch January 23, 2024 06:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants