mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-06 22:30:56 +03:00
HTTPD, WebDAV: use http.ResponseController
backport from Enterprise edition Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
@@ -35,6 +35,17 @@ import (
|
||||
type Connection struct {
|
||||
*common.BaseConnection
|
||||
request *http.Request
|
||||
rc *http.ResponseController
|
||||
}
|
||||
|
||||
func newConnection(conn *common.BaseConnection, w http.ResponseWriter, r *http.Request) *Connection {
|
||||
rc := http.NewResponseController(w)
|
||||
responseControllerDeadlines(rc, time.Time{}, time.Time{})
|
||||
return &Connection{
|
||||
BaseConnection: conn,
|
||||
request: r,
|
||||
rc: rc,
|
||||
}
|
||||
}
|
||||
|
||||
// GetClientVersion returns the connected client's version.
|
||||
@@ -60,6 +71,9 @@ func (c *Connection) GetRemoteAddress() string {
|
||||
|
||||
// Disconnect closes the active transfer
|
||||
func (c *Connection) Disconnect() (err error) {
|
||||
if c.rc != nil {
|
||||
responseControllerDeadlines(c.rc, time.Now().Add(5*time.Second), time.Now().Add(5*time.Second))
|
||||
}
|
||||
return c.SignalTransfersAbort()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user