Downloads.download() error

import Downloads
Downloads.download("https://www.hkex.com.hk/eng/stat/smstat/dayquot/d250806e.htm")

produces the error:

ERROR: RequestError: HTTP/2 stream 1 was not closed cleanly: INTERNAL_ERROR (err 2) while requesting https://www.hkex.com.hk/eng/stat/smstat/dayquot/d250806e.htm

but the URL is fine to be opened in a browser.

I’m not familiar with web techs. Please suggest how to fix it. Thanks.

Try:

using HTTP
hr = HTTP.get(url)
2 Likes

Neither am I with that particular error.

download() doesn’t support HTTP/3 (that always uses https), I believe, neither HTTP/2 apparently (at least not always).

In many cases you could change https → http, and both are supported (by the web server; the latter always by Julia). In most cases it would work, but not here (an issue with the server):

julia> using Downloads
julia> Downloads.download("http://www.hkex.com.hk/eng/stat/smstat/dayquot/d250806e.htm")
ERROR: RequestError: Operation too slow. Less than 1 bytes/sec transferred the last 20 seconds while requesting http://www.hkex.com.hk/eng/stat/smstat/dayquot/d250806e.htm

however this worked quickly (so seemingly NOT the same web server serving the above file despite same host?)::

julia> Downloads.download("http://www.hkex.com.hk/")
"/tmp/jl_HMxKLOjudO"

The issue seems to be Julia’s built in dependency curl (at least how Julia configures it), and I would usually think curl handles anything out there…:

[2] with_handle(f::Downloads.var"#23#24"{IOStream, Base.DevNull, Nothing, Vector{Pair{String, String}}, Float64, Nothing, Bool, Nothing, Bool, Nothing, String, Bool, Bool}, handle::Downloads.Curl.Easy)
@ Downloads.Curl ~/.julia/juliaup/julia-1.12.0-rc1+0.x64.linux.gnu/share/julia/stdlib/v1.12/Downloads/src/Curl/Curl.jl:105

I looked into if better on 1.12-rc1, or any newer (no).

I’m not sure why this rather worked, seemingly it instructs using the older HTTP/1.1

julia> hr = HTTP.get(“https://www.hkex.com.hk/eng/stat/smstat/dayquot/d250806e.htm”)HTTP.Messages.Response:“”"HTTP/1.1 200 OK
24411176-byte body“”"

Maybe Curl config in Julia can be changed to always work?

$ curl https://www.hkex.com.hk/eng/stat/smstat/dayquot/d250806e.htm
curl: (92) HTTP/2 stream 0 was not closed cleanly: INTERNAL_ERROR (err 2)

$ wget https://www.hkex.com.hk/eng/stat/smstat/dayquot/d250806e.htm
--2025-08-07 18:23:23--  https://www.hkex.com.hk/eng/stat/smstat/dayquot/d250806e.htm
Resolving www.hkex.com.hk (www.hkex.com.hk)... 2.19.176.170, 2.19.176.185
Tengist www.hkex.com.hk (www.hkex.com.hk)|2.19.176.170|:443... connected.
HTTP fyrirspurn send, bíð svars... [HTTP query sent, waiting for answer]

“Closed as not planned” there at Curl/upstream, apparently because “not-a-curl-bug” then what, bad config at that web server?

1 Like