소스 검색

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 3 년 전
부모
커밋
fa102822bb
1개의 변경된 파일5개의 추가작업 그리고 3개의 파일을 삭제
  1. +5
    -3
      plugins/viewhtml/plugin.go

+ 5
- 3
plugins/viewhtml/plugin.go 파일 보기

@@ -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)
})


불러오는 중...
취소
저장