mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-02 19:57:35 +03:00
http3: discard negative content-length header when writing response (#3983)
* response writer: discard negative content-length header * shorten comment --------- Co-authored-by: Marten Seemann <martenseemann@gmail.com>
This commit is contained in:
parent
5a22ac8970
commit
2183283622
1 changed files with 3 additions and 2 deletions
|
@ -64,9 +64,10 @@ func (w *responseWriter) WriteHeader(status int) {
|
|||
w.header.Set("Date", time.Now().UTC().Format(http.TimeFormat))
|
||||
}
|
||||
// Content-Length checking
|
||||
// use ParseUint instead of ParseInt, as negative values are invalid
|
||||
if clen := w.header.Get("Content-Length"); clen != "" {
|
||||
if cl, err := strconv.ParseInt(clen, 10, 64); err == nil {
|
||||
w.contentLen = cl
|
||||
if cl, err := strconv.ParseUint(clen, 10, 63); err == nil {
|
||||
w.contentLen = int64(cl)
|
||||
} else {
|
||||
// emit a warning for malformed Content-Length and remove it
|
||||
w.logger.Errorf("Malformed Content-Length %s", clen)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue