diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2023-05-13 22:04:57 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-13 16:04:57 +0200 |
commit | a94a8d0ab1f6c9d63ae607dfec866c47ae3e4b5c (patch) | |
tree | 84c1e5e4f3423ed952b573ab1403844de2951cb7 /modules/context | |
parent | f74501609246646a3ab62b37a1e7469d6fea63b7 (diff) | |
download | gitea-a94a8d0ab1f6c9d63ae607dfec866c47ae3e4b5c.tar.gz gitea-a94a8d0ab1f6c9d63ae607dfec866c47ae3e4b5c.zip |
Use standard HTTP library to serve files (#24693)
`http.ServeFile/ServeContent` handles `If-xxx`, `Content-Length`,
`Range` and `Etag` correctly
After this PR, storage files (eg: avatar) could be responded with
correct Content-Length.
Diffstat (limited to 'modules/context')
-rw-r--r-- | modules/context/context_test.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/modules/context/context_test.go b/modules/context/context_test.go index a6facc9788..033ce2ef0a 100644 --- a/modules/context/context_test.go +++ b/modules/context/context_test.go @@ -5,16 +5,16 @@ package context import ( "net/http" + "net/http/httptest" "testing" - "code.gitea.io/gitea/modules/httplib" "code.gitea.io/gitea/modules/setting" "github.com/stretchr/testify/assert" ) func TestRemoveSessionCookieHeader(t *testing.T) { - w := httplib.NewMockResponseWriter() + w := httptest.NewRecorder() w.Header().Add("Set-Cookie", (&http.Cookie{Name: setting.SessionConfig.CookieName, Value: "foo"}).String()) w.Header().Add("Set-Cookie", (&http.Cookie{Name: "other", Value: "bar"}).String()) assert.Len(t, w.Header().Values("Set-Cookie"), 2) |