Fixing profile image tag (#7435)
* Fixing profile image tag * Fixing unit test * Fixing unit test
Этот коммит содержится в:
коммит произвёл
Joram Wilander
родитель
0643bf5159
Коммит
99b7d65504
@@ -571,10 +571,10 @@ func getProfileImage(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
w.Header().Set("Cache-Control", "max-age=300, public") // 5 mins
|
w.Header().Set("Cache-Control", "max-age=300, public") // 5 mins
|
||||||
} else {
|
} else {
|
||||||
w.Header().Set("Cache-Control", "max-age=86400, public") // 24 hrs
|
w.Header().Set("Cache-Control", "max-age=86400, public") // 24 hrs
|
||||||
|
w.Header().Set(model.HEADER_ETAG_SERVER, etag)
|
||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "image/png")
|
w.Header().Set("Content-Type", "image/png")
|
||||||
w.Header().Set(model.HEADER_ETAG_SERVER, etag)
|
|
||||||
w.Write(img)
|
w.Write(img)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -684,8 +684,8 @@ func TestUserCreateImage(t *testing.T) {
|
|||||||
} else {
|
} else {
|
||||||
etag := resp.Header.Get(model.HEADER_ETAG_SERVER)
|
etag := resp.Header.Get(model.HEADER_ETAG_SERVER)
|
||||||
resp2, _ := Client.DoApiGet("/users/"+user.Id+"/image", "", etag)
|
resp2, _ := Client.DoApiGet("/users/"+user.Id+"/image", "", etag)
|
||||||
if resp2.StatusCode != 304 {
|
if resp2.StatusCode == 304 {
|
||||||
t.Fatal("Should have hit etag")
|
t.Fatal("Shouldn't have hit etag")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -214,10 +214,10 @@ func getProfileImage(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
w.Header().Set("Cache-Control", fmt.Sprintf("max-age=%v, public", 5*60)) // 5 mins
|
w.Header().Set("Cache-Control", fmt.Sprintf("max-age=%v, public", 5*60)) // 5 mins
|
||||||
} else {
|
} else {
|
||||||
w.Header().Set("Cache-Control", fmt.Sprintf("max-age=%v, public", 24*60*60)) // 24 hrs
|
w.Header().Set("Cache-Control", fmt.Sprintf("max-age=%v, public", 24*60*60)) // 24 hrs
|
||||||
|
w.Header().Set(model.HEADER_ETAG_SERVER, etag)
|
||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "image/png")
|
w.Header().Set("Content-Type", "image/png")
|
||||||
w.Header().Set(model.HEADER_ETAG_SERVER, etag)
|
|
||||||
w.Write(img)
|
w.Write(img)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -866,8 +866,8 @@ func TestGetProfileImage(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_, resp = Client.GetProfileImage(user.Id, resp.Etag)
|
_, resp = Client.GetProfileImage(user.Id, resp.Etag)
|
||||||
if resp.StatusCode != http.StatusNotModified {
|
if resp.StatusCode == http.StatusNotModified {
|
||||||
t.Fatal("Should have hit etag")
|
t.Fatal("Shouldn't have hit etag")
|
||||||
}
|
}
|
||||||
|
|
||||||
_, resp = Client.GetProfileImage("junk", "")
|
_, resp = Client.GetProfileImage("junk", "")
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user