line / line-bot-sdk-go

LINE Messaging API SDK for Go
https://developers.line.biz/en/docs/messaging-api/overview/
Apache License 2.0
891 stars 236 forks source link

Proposal for calling head method #491

Open kevin19930919 opened 1 week ago

kevin19930919 commented 1 week ago

We find that when we try to fetch large file content with API GET https://api-data.line.me/v2/bot/message/{messageId}/content, the connection will be closed by line client when it exceed 100s. Then we get response like:

HTTP/2 stream 1 was not closed cleanly: INTERNAL_ERROR (err 2)

I use curl to get the complete information:

Note: Unnecessary use of -X or --request, GET is already inferred.
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:--  0:00:02 --:--:--     0*   Trying 147.92.191.80:443...
* Connected to api-data.line.me (147.92.191.80) port 443 (#0)
* ALPN: offers h2,http/1.1
* (304) (OUT), TLS handshake, Client hello (1):
} [321 bytes data]
*  CAfile: /etc/ssl/cert.pem
*  CApath: none
* (304) (IN), TLS handshake, Server hello (2):
{ [122 bytes data]
* (304) (IN), TLS handshake, Unknown (8):
{ [19 bytes data]
* (304) (IN), TLS handshake, Certificate (11):
{ [2731 bytes data]
* (304) (IN), TLS handshake, CERT verify (15):
{ [264 bytes data]
* (304) (IN), TLS handshake, Finished (20):
{ [52 bytes data]
* (304) (OUT), TLS handshake, Finished (20):
} [52 bytes data]
* SSL connection using TLSv1.3 / AEAD-AES256-GCM-SHA384
* ALPN: server accepted h2
* Server certificate:
*  subject: C=JP; ST=Tokyo; L=Chiyoda-ku; O=LY Corporation; CN=*.line.me
*  start date: Aug  8 04:31:02 2024 GMT
*  expire date: Sep  9 04:31:01 2025 GMT
*  subjectAltName: host "api-data.line.me" matched cert's "*.line.me"
*  issuer: C=BE; O=GlobalSign nv-sa; CN=GlobalSign RSA OV SSL CA 2018
*  SSL certificate verify ok.
* using HTTP/2
* h2h3 [:method: GET]
* h2h3 [:path: /v2/bot/message/xxxxxx/content]
* h2h3 [:scheme: https]
* h2h3 [:authority: api-data.line.me]
* h2h3 [accept: */*]
* h2h3 [authorization: Bearer xxxxxx]
* h2h3 [user-agent: insomnia/10.1.0]
* Using Stream ID: 1 (easy handle 0x13e80a800)
> GET /v2/bot/message/xxxx/content HTTP/2
> Host: api-data.line.me
> accept: */*
> authorization: Bearer xxxxxx
> user-agent: insomnia/10.1.0
>
< HTTP/2 200
< server: openresty
< date: Fri, 18 Oct 2024 13:35:09 GMT
< content-type: application/postscript
< content-length: 445151017
< accept-ranges: bytes
< cache-control: max-age=86400
< expires: Sat, 19 Oct 2024 13:35:08 GMT
< x-content-type-options: nosniff
< last-modified: Fri, 18 Oct 2024 08:15:12 GMT
< x-line-request-id: b9fe8504-467b-d511-89ea-d377efeb40b3
<
{ [16127 bytes data]
 23  424M   23  101M    0     0  1017k      0  0:07:07  0:01:42  0:05:25 1035k* HTTP/2 stream 1 was not closed cleanly: INTERNAL_ERROR (err 2)
 23  424M   23  101M    0     0  1017k      0  0:07:07  0:01:42  0:05:25 1050k
* Connection #0 to host api-data.line.me left intact
curl: (92) HTTP/2 stream 1 was not closed cleanly: INTERNAL_ERROR (err 2)

We would like to get the file size by calling HEAD method at 1st, so we can decided our next step. Can we have a head method at linebot/client.go? If it's ok, I would love to add it.

System Informations

Expected Behavior

Current Behavior

Steps to Reproduce

1. 1. 1. 1.

Logs

habara-k commented 2 days ago

Thank you for using the line-bot-sdk-go. Currently, the connection may be cut off due to server-side timeouts depending on the response size.

We would like to get the file size by calling the HEAD method first, so we can decide our next step.

Could you please let us know specifically what you aim to achieve by obtaining the file size?