Mac-Osx

在 Catalina OSX 10.15.1 上使用 curl 上傳 zip 時出錯

  • November 5, 2019

使用預裝在 OSx 中的 curl 命令工具。

命令如下:

curl -v -H 'Authorization:Bearer xxx' -H 'Accept:application/json' -F 'funzione=uploadPacket' -F 'folder_id=159' -F 'userfile=@//Users/mediabook/Desktop/forCatalina.zip' https://mysite/api/extGetNote

在以前的系統中,它工作正常。現在使用 Catalina(OSX 10.15.0 和 10.15.1)報告此錯誤:

curl: (92) HTTP/2 stream 0 was not closed cleanly: PROTOCOL_ERROR (err 1)

詳細:

*   Trying 95.141.37.143...
* TCP_NODELAY set
* Connected to mysite (95.141.37.143) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/cert.pem
CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN, server accepted to use h2
* Server certificate:
*  subject: CN= mysite
*  start date: Oct 22 08:06:23 2019 GMT
*  expire date: Jan 20 08:06:23 2020 GMT
*  subjectAltName: host "mysite" matched cert's "mysite"
*  issuer: C=US; O=Let's Encrypt; CN=Let's Encrypt Authority X3
*  SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x7fb230008c00)
POST /api/extGetNote HTTP/2
Host: mysite
User-Agent: curl/7.64.1
Authorization:Bearer xxx
Accept:application/json
Content-Length: 160026
Content-Type: multipart/form-data; boundary=------------------------6cec1f7bf39b0dbf

* Connection state changed (MAX_CONCURRENT_STREAMS == 128)!
* We are completely uploaded and fine
* HTTP/2 stream 0 was not closed cleanly: PROTOCOL_ERROR (err 1)
* stopped the pause stream!
* Connection #0 to host mysite left intact
curl: (92) HTTP/2 stream 0 was not closed cleanly: PROTOCOL_ERROR (err 1)
* Closing connection 0

與 jpeg 附件相同的命令有效!僅 zip 文件出錯。該文件為 160 Kb…。

有任何想法嗎?

謝謝!

您正在使用 HTTP/2。將選項添加--http1.1到您的curl命令。

引用自:https://serverfault.com/questions/990640