Skip to content

Modernize Downloader#3143

Open
otbutz wants to merge 11 commits intographhopper:masterfrom
otbutz:http_client
Open

Modernize Downloader#3143
otbutz wants to merge 11 commits intographhopper:masterfrom
otbutz:http_client

Conversation

@otbutz
Copy link
Copy Markdown
Contributor

@otbutz otbutz commented Mar 13, 2025

  • Reimplement Downloader based on java.net HttpClient
  • allow callers to skip transport compression
  • use a proper User-Agent e.g graphhopper/11.0
  • handle partial downloads

@otbutz otbutz marked this pull request as ready for review March 31, 2025 10:48
@otbutz otbutz marked this pull request as draft March 31, 2025 10:48
@otbutz otbutz marked this pull request as ready for review March 31, 2025 10:51
Comment thread core/src/main/java/com/graphhopper/reader/dem/SonnyProvider.java
@otbutz
Copy link
Copy Markdown
Contributor Author

otbutz commented Dec 17, 2025

@karussell successfully tested with all our providers. This should also make elevation handling much more robust. GraphHopper can now be safely stopped during the import phase without corrupting the cache 🙂

@otbutz otbutz mentioned this pull request Jan 15, 2026
@karussell
Copy link
Copy Markdown
Member

Hm, I do not see the benefits here. All the advantages you listed could as well be implemented for HttpURLConnection. Or am I misunderstanding something?

GraphHopper can now be safely stopped during the import phase without corrupting the cache 🙂

Because of storing the data into a .part file first? Wouldn't this work for the old HttpURLConnection too?

@otbutz
Copy link
Copy Markdown
Contributor Author

otbutz commented Jan 21, 2026

Hm, I do not see the benefits here. All the advantages you listed could as well be implemented for HttpURLConnection. Or am I misunderstanding something?

The API is an ugly relic from the Java 1.1 era. The main benefit though is that HttpClient supports HTTP/2 (and even HTTP/3 with Java 26+), which saves bandwidth because they use a binary protocol with header compression. The new client also supports asynchronous calls, if we want to add some kind of prefetching 🙂

GraphHopper can now be safely stopped during the import phase without corrupting the cache 🙂

Because of storing the data into a .part file first? Wouldn't this work for the old HttpURLConnection too?

Sure. I finally managed to pinpoint this bug while testing my HttpClient changes and simply added it as part of this PR 🤷

@otbutz otbutz mentioned this pull request Mar 21, 2026
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