Explorar el Código

HTML image proxy: handle missing Content-Length

This is less than ideal, but we still won't end up over-reading because
we're using a LimitedReader here.
master
Drew DeVault hace 3 años
padre
commit
fa102822bb
Se han modificado 1 ficheros con 5 adiciones y 3 borrados
  1. +5
    -3
      plugins/viewhtml/plugin.go

+ 5
- 3
plugins/viewhtml/plugin.go Ver fichero

@@ -58,11 +58,13 @@ func init() {
}

size, err := strconv.Atoi(resp.Header.Get("Content-Length"))
if err != nil || size > proxyMaxSize {
return echo.NewHTTPError(http.StatusBadRequest, "invalid resource length")
if err == nil {
if size > proxyMaxSize {
return echo.NewHTTPError(http.StatusBadRequest, "invalid resource length")
}
ctx.Response().Header().Set("Content-Length", strconv.Itoa(size))
}

ctx.Response().Header().Set("Content-Length", strconv.Itoa(size))
lr := io.LimitedReader{resp.Body, int64(proxyMaxSize)}
return ctx.Stream(http.StatusOK, mediaType, &lr)
})


Cargando…
Cancelar
Guardar