• With issues:
  • Use the search tool before opening a new issue.
  • Please provide source code and commit sha if you found a bug.
  • Review existing issues and provide feedback or react to them.

Description

when i provide a download url with c.File(), but i limit download speed, so the download will run long time, i cancel chrome download task, but c.File() is also runing

How to reproduce

package main

import (
    "github.com/gin-gonic/gin"
)

func main() {
    g := gin.Default()
    g.GET("/hello/test", func(c *gin.Context) {
        c.File("./bigFile")
    })
    g.Run(":9000")
}

Expectations

$ wget http://localhost:9000/hello/test
ctrc+c

the c.File() will stop send data

Actual result

$ wget http://localhost:9000/hello/test
ctrc+c
the c.File() is still runing , until file is end or write is blocked, that request not exit

Environment

  • go version: 1.20.5
  • gin version (or commit ref): v1.9.1
  • operating system: windows

Comment From: Sprlia

this may cause by https, ssl cert is not secure, but so weird

Comment From: araujo88

I was able to run without any errors:

go run main.go 
[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.

[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
 - using env:   export GIN_MODE=release
 - using code:  gin.SetMode(gin.ReleaseMode)

[GIN-debug] GET    /hello/test               --> main.main.func1 (3 handlers)
[GIN-debug] [WARNING] You trusted all proxies, this is NOT safe. We recommend you to set a value.
Please check https://pkg.go.dev/github.com/gin-gonic/gin#readme-don-t-trust-all-proxies for details.
[GIN-debug] Listening and serving HTTP on :9000
[GIN] 2023/08/08 - 01:09:36 | 200 |  2.043687188s |             ::1 | GET      "/hello/test"

wget http://localhost:9000/hello/test
--2023-08-08 01:08:27--  http://localhost:9000/hello/test
Resolving localhost (localhost)... ::1, 127.0.0.1
Connecting to localhost (localhost)|::1|:9000... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1073741824 (1,0G) [application/x-raw-disk-image]
Saving to: ‘test’

test                 37%[======>             ] 379,84M   380MB/s               ^C

Can you provide more information?