HEAD requests timing out
WHAT
HEAD requests made with gleam_httpc are just timing out for me, whereas the exact same HEAD request is returning in less than 1 second via hackney or via curl.
REPRO
Here's my repo where I'm testing this out:
https://github.com/ToddG/gleam-sample-apps/blob/ba399c252f6da9f1ed5dcfc3388e077ea6f5c952/httprequest/src/httprequest.gleam#L50C1-L65C2
This will time out:
pub fn send_head_request(url: String) {
io.println("HEAD request : " <> url)
let assert Ok(req) = request.to(url)
let req = request.set_method(req, http.Head)
let config = httpc.configure() |> httpc.follow_redirects(True) |> httpc.timeout(4000)
use resp <- result.try(httpc.dispatch(config, req))
Ok(resp)
}
This returns in ~ 1 s or less:
pub fn send_head_request_via_hackney(url: String) {
io.println("HEAD request : " <> url)
let assert Ok(req) = request.to(url)
let req = request.set_method(req, http.Head)
use resp <- result.try(hackney.send(req))
Ok(resp)
}
And this works fine, too:
curl --verbose -I "https://services3.arcgis.com/T4QMspbfLg3qTGWY/arcgis/rest/services/WFIGS_Incident_Locations_Last24h/FeatureServer/0/query?where=1%3D1&outFields=*&outSR=4326&f=json"
Can't reproduce, code:
import gleam/http
import gleam/http/request
import gleam/httpc
import gleam/io
import gleam/result
pub fn main() {
let assert Ok(resp) =
send_head_request(
"https://services3.arcgis.com/T4QMspbfLg3qTGWY/arcgis/rest/services/WFIGS_Incident_Locations_Last24h/FeatureServer/0/query?where=1%3D1&outFields=*&outSR=4326&f=json",
)
echo resp
}
pub fn send_head_request(url: String) {
io.println("HEAD request : " <> url)
let assert Ok(req) = request.to(url)
let req = request.set_method(req, http.Head)
let config =
httpc.configure() |> httpc.follow_redirects(True) |> httpc.timeout(4000)
use resp <- result.try(httpc.dispatch(config, req))
Ok(resp)
}
Windows 11 25H2 Gleam 1.12.0 -> upgraded to 1.13.0 with the same results Erlang/OTP 28
Console output:
src\testing.gleam:12
Response(200, [#("cache-control", "public, max-age=300, s-maxage=300"), #("connection", "close"), #("date", "Sun, 02 Nov 2025 00:55:11 GMT"), #("accept-ranges", "bytes"), #("etag", "sd274873_72363322"), #("vary", "X-Esri-Authorization"), #("content-length", "83798"), #("content-type", "application/json; charset=utf-8"), #("last-modified", "Sun, 02 Nov 2025 00:52:07 GMT"), #("request-context", "appId=cid-v1:fd6e1bc1-25b9-4c44-b84e-cad200af25b3"), #("request-context", "appId=cid-v1:76c62117-7333-4258-8b6f-ed44d6def619"), #("x-arcgis-upstream", "us1h03c00"), #("strict-transport-security", "max-age=63072000"), #("x-arcgis-trace-id", "20251102T005443Z-15d8777fd64xvgq8hC1WAW67r80000000c900000000076t1"), #("x-esri-query-readonly-replica", "true"), #("x-esri-query-request-units", "2"), #("x-esri-tiles-basic-query-mode", "true"), #("x-esri-tiles-basic-query-type", "Basic"), #("x-esri-org-request-units-per-min", "usage=4553;max=115200"), #("x-esri-query-geometry-field-name", "Shape"), #("x-arcgis-correlation-id", "32ef992c56d9a069"), #("x-arcgis-instance", "2hyjso3px00000F"), #("access-control-expose-headers", "Request-Context"), #("access-control-allow-origin", "*"), #("access-control-allow-headers", "Content-Type, Authorization, X-Esri-Authorization"), #("access-control-allow-credentials", "true"), #("x-azure-ref", "20251102T005511Z-15d8777fd64x92kvhC1WAWbb4s0000000cm000000000899d"), #("x-fd-int-roxy-purgeid", "0"), #("x-cache", "TCP_HIT"), #("x-cache-info", "L1_T2")], "")
I've not been able to reproduce it either. Is it a particular URL that has the problem?
I haven't tested on any other urls yet. I was using this one b/c it has data I'm curious about, and because curl -I ... (head request) works on it.
I just tried folo's repro, and this still repros on my machine:
✔ /media/toddg/data1/repos/personal/gleam/gleam-sample-apps/httprequest/src [toddg/httprequest|✚ 1]
06:55 $ gleam run
Compiled in 0.02s
Running httprequest.main
HEAD request : https://services3.arcgis.com/T4QMspbfLg3qTGWY/arcgis/rest/services/WFIGS_Incident_Locations_Last24h/FeatureServer/0/query?where=1%3D1&outFields=*&outSR=4326&f=json
runtime error: let assert
Pattern match failed, no pattern matched the value.
unmatched value:
Error(ResponseTimeout)
stacktrace:
httprequest.main src/httprequest.gleam:8
✘-1 /media/toddg/data1/repos/personal/gleam/gleam-sample-apps/httprequest/src [toddg/httprequest|✚ 1]
06:55 $ cat httprequest.gleam
import gleam/http
import gleam/http/request
import gleam/httpc
import gleam/io
import gleam/result
pub fn main() {
let assert Ok(resp) =
send_head_request(
"https://services3.arcgis.com/T4QMspbfLg3qTGWY/arcgis/rest/services/WFIGS_Incident_Locations_Last24h/FeatureServer/0/query?where=1%3D1&outFields=*&outSR=4326&f=json",
)
echo resp
}
pub fn send_head_request(url: String) {
io.println("HEAD request : " <> url)
let assert Ok(req) = request.to(url)
let req = request.set_method(req, http.Head)
let config =
httpc.configure() |> httpc.follow_redirects(True) |> httpc.timeout(4000)
use resp <- result.try(httpc.dispatch(config, req))
Ok(resp)
}
LMK if there's something you'd like me to try on my machine to narrow this down. In the meantime, I'm not blocked, as I can use hackney for my head requests.
Linux system76 6.14.0-33-generic #33~24.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Sep 19 17:02:30 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
I suppose it has something to do with your setup that we don't have. Is there anything unusual about your network?
I don't think so. However, I'll try to reproduce on separate machines and on a different network.
Ok, I rebooted my machine after being gone for a few days. Now httpc head requests are working just fine. Hah! I have no idea what the issue was.
Closing :-)
oooh spooky! I wonder what it was