Skip to content

Commit

Permalink
upload_by_url: Handle case where content-length header is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
Brawl345 committed Nov 8, 2024
1 parent 94022c4 commit 8dd65fa
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion plugin/upload_by_url/upload_by_url.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,19 @@ func onFileLink(b *gotgbot.Bot, c plugin.GobotContext) error {
return nil
}

fileSize, err := strconv.ParseInt(resp.Header.Get("Content-Length"), 10, 64)
contentLength := resp.Header.Get("Content-Length")
if contentLength == "" {
log.Debug().
Str("url", url).
Msg("Content-Length header is empty")
return nil
}

fileSize, err := strconv.ParseInt(contentLength, 10, 64)
if err != nil {
log.Err(err).
Str("url", url).
Str("contentLength", contentLength).
Msg("Failed to parse content length")
return nil
}
Expand Down

0 comments on commit 8dd65fa

Please sign in to comment.