diff options
author | Corey Hulen <corey@hulen.com> | 2017-09-19 13:34:39 -0700 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2017-09-19 16:34:39 -0400 |
commit | 99b7d65504ce729db4255f2d31def0859d36e87f (patch) | |
tree | 0aa6fb4a00104931abcb0cf1bc980e749789b49d | |
parent | 0643bf51595396a7dab88be07a9f2b50410dedea (diff) | |
download | chat-99b7d65504ce729db4255f2d31def0859d36e87f.tar.gz chat-99b7d65504ce729db4255f2d31def0859d36e87f.tar.bz2 chat-99b7d65504ce729db4255f2d31def0859d36e87f.zip |
Fixing profile image tag (#7435)
* Fixing profile image tag
* Fixing unit test
* Fixing unit test
-rw-r--r-- | api/user.go | 2 | ||||
-rw-r--r-- | api/user_test.go | 4 | ||||
-rw-r--r-- | api4/user.go | 2 | ||||
-rw-r--r-- | api4/user_test.go | 4 |
4 files changed, 6 insertions, 6 deletions
diff --git a/api/user.go b/api/user.go index d95d775e4..1ca46bd56 100644 --- a/api/user.go +++ b/api/user.go @@ -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 } else { 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(model.HEADER_ETAG_SERVER, etag) w.Write(img) } } diff --git a/api/user_test.go b/api/user_test.go index 44ee1bfb0..5b6309bcf 100644 --- a/api/user_test.go +++ b/api/user_test.go @@ -684,8 +684,8 @@ func TestUserCreateImage(t *testing.T) { } else { etag := resp.Header.Get(model.HEADER_ETAG_SERVER) resp2, _ := Client.DoApiGet("/users/"+user.Id+"/image", "", etag) - if resp2.StatusCode != 304 { - t.Fatal("Should have hit etag") + if resp2.StatusCode == 304 { + t.Fatal("Shouldn't have hit etag") } } diff --git a/api4/user.go b/api4/user.go index b0d9ac699..cb1ae0fa3 100644 --- a/api4/user.go +++ b/api4/user.go @@ -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 } else { 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(model.HEADER_ETAG_SERVER, etag) w.Write(img) } } diff --git a/api4/user_test.go b/api4/user_test.go index 1b9553d2d..6a6436896 100644 --- a/api4/user_test.go +++ b/api4/user_test.go @@ -866,8 +866,8 @@ func TestGetProfileImage(t *testing.T) { } _, resp = Client.GetProfileImage(user.Id, resp.Etag) - if resp.StatusCode != http.StatusNotModified { - t.Fatal("Should have hit etag") + if resp.StatusCode == http.StatusNotModified { + t.Fatal("Shouldn't have hit etag") } _, resp = Client.GetProfileImage("junk", "") |