1
0
mirror of https://github.com/drakkan/sftpgo.git synced 2025-12-05 22:17:20 +02:00

WebClient: return proper status code for http.MaxBytesError

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino
2023-02-27 11:03:05 +01:00
parent 874776bd12
commit 561976bcd0
5 changed files with 27 additions and 20 deletions

View File

@@ -122,7 +122,11 @@ func getMappedStatusCode(err error) int {
case errors.Is(err, common.ErrOpUnsupported):
statusCode = http.StatusBadRequest
default:
statusCode = http.StatusInternalServerError
if _, ok := err.(*http.MaxBytesError); ok {
statusCode = http.StatusRequestEntityTooLarge
} else {
statusCode = http.StatusInternalServerError
}
}
return statusCode
}