I have a url that works fine in Google Chrome, but fails when used in httr2. The actual failure message varies from run to run, often just timing out ("less than 1 byte received in 600 seconds").
I've tried with and without the user agent string with no change.
Can someone explain what I'm doing wrong here please?
> url = "https://api.nasdaq.com/api/screener/stocks?tableonly=false&limit=25&exchange=AMEX&download=true"
> response <-
+ httr2::request(url) %>%
+ httr2::req_user_agent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36") %>%
+ httr2::req_perform(verbosity = 3)
* Host api.nasdaq.com:443 was resolved.
* IPv6: (none)
* IPv4: 23.64.34.95
* Trying 23.64.34.95:443...
* schannel: disabled automatic use of client certificate
* Connected to api.nasdaq.com (23.64.34.95) port 443
* using HTTP/1.x
-> GET /api/screener/stocks?tableonly=false&limit=25&exchange=AMEX&download=true HTTP/1.1
-> Host: api.nasdaq.com
-> User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36
-> Accept: */*
-> Accept-Encoding: deflate, gzip
->
* Request completely sent off
* schannel: server closed abruptly (missing close_notify)
* closing connection #9
Error in `httr2::req_perform()`:
! Failed to perform HTTP request.
Caused by error in `curl::curl_fetch_memory()`:
! Failure when receiving data from the peer [api.nasdaq.com]
Run `rlang::last_trace()` to see where the error occurred.
> rlang::last_trace()
<error/httr2_failure>
Error in `httr2::req_perform()`:
! Failed to perform HTTP request.
Caused by error in `curl::curl_fetch_memory()`:
! Failure when receiving data from the peer [api.nasdaq.com]
---
Backtrace:
▆
1. ├─... %>% httr2::req_perform(verbosity = 3)
2. └─httr2::req_perform(., verbosity = 3)
3. └─base::tryCatch(...)
4. └─base (local) tryCatchList(expr, classes, parentenv, handlers)
5. └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
6. └─value[[3L]](cond)
>