Curl 命令冻结并且无法按预期工作

Curl 命令冻结并且无法按预期工作

我想卷曲AMD 网站。我可以使用 wget,但我不知道如何让 curl 工作。

# wget command works if the header is added
wget -U 'Mozilla/5.0' https://www.amd.com/en.html
Resolving www.amd.com (www.amd.com)... 104.89.160.108
Connecting to www.amd.com (www.amd.com)|104.89.160.108|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘en.html’

# Check curl version
$ curl --version
curl 8.4.0 (x86_64-conda-linux-gnu) libcurl/8.4.0 OpenSSL/3.0.12 zlib/1.2.13 libssh2/1.10.0 nghttp2/1.57.0

2023-12-16 08:47:08 (1.56 MB/s) - ‘en.html’ saved [277861]

# First curl command gives error
$ curl https://www.amd.com/en.html
curl: (92) HTTP/2 stream 1 was not closed cleanly: INTERNAL_ERROR (err 2)

# Second curl command freeze forever
$ curl -A 'Mozilla/5.0' --http1.1 -v https://www.amd.com/en.html
*   Trying 23.46.196.82:443...
* Connected to www.amd.com (23.46.196.82) port 443
* ALPN: curl offers http/1.1
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
*  CAfile: /home/winston/anaconda3/ssl/cacert.pem
*  CApath: none
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
* ALPN: server accepted http/1.1
* Server certificate:
*  subject: C=US; ST=CALIFORNIA; L=Santa Clara; O=Advanced Micro Devices, Inc.; CN=amd.com
*  start date: Feb 21 00:00:00 2023 GMT
*  expire date: Feb 20 23:59:59 2024 GMT
*  subjectAltName: host "www.amd.com" matched cert's "www.amd.com"
*  issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=GeoTrust RSA CA 2018
*  SSL certificate verify ok.
* using HTTP/1.1
> GET /en.html HTTP/1.1
> Host: www.amd.com
> User-Agent: Mozilla/5.0
> Accept: */*
> 
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* old SSL session ID is stale, removing

答案1

我发布了同样的问题curl github 仓库并得到了以下回应。

  • curl 命令没有超时机制。您可以使用--max-time标志设置自己的超时时间。
  • 有些网站不响应,除非你提供正确的参数(例如 user-agent、accept-encoding 和 connection)。每个网站的情况都不一样。

相关内容