Commit 882ed939 authored by Nick Thomas's avatar Nick Thomas

Merge branch 'preserve-http-1-0-cache-headers' into 'master'

Keep HTTP 1.0 cache headers from sendurl proxies

See merge request gitlab-org/gitlab-workhorse!431
parents 8ec357ee 11795431
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
Formerly known as 'gitlab-git-http-server'. Formerly known as 'gitlab-git-http-server'.
Next
- Keep HTTP 1.0 cache headers from sendurl proxies
v 8.13.0 v 8.13.0
- Preserve original HTTP cache headers when proxying with sendurl !428 - Preserve original HTTP cache headers when proxying with sendurl !428
......
...@@ -42,6 +42,8 @@ var rangeHeaderKeys = []string{ ...@@ -42,6 +42,8 @@ var rangeHeaderKeys = []string{
var preserveHeaderKeys = map[string]bool{ var preserveHeaderKeys = map[string]bool{
"Cache-Control": true, "Cache-Control": true,
"Expires": true, "Expires": true,
"Date": true, // Support for HTTP 1.0 proxies
"Pragma": true, // Support for HTTP 1.0 proxies
} }
// httpTransport defines a http.Transport with values // httpTransport defines a http.Transport with values
......
...@@ -30,8 +30,10 @@ func testEntryServer(t *testing.T, requestURL string, httpHeaders http.Header, a ...@@ -30,8 +30,10 @@ func testEntryServer(t *testing.T, requestURL string, httpHeaders http.Header, a
// The server returns a Content-Disposition // The server returns a Content-Disposition
w.Header().Set("Content-Disposition", "attachment; filename=\"archive.txt\"") w.Header().Set("Content-Disposition", "attachment; filename=\"archive.txt\"")
w.Header().Set("Cache-Control", "no-store") w.Header().Set("Cache-Control", "no-cache")
w.Header().Set("Expires", "") w.Header().Set("Expires", "")
w.Header().Set("Date", "Wed, 21 Oct 2015 05:28:00 GMT")
w.Header().Set("Pragma", "no-cache")
SendURL.Inject(w, r, data) SendURL.Inject(w, r, data)
} }
...@@ -48,6 +50,8 @@ func testEntryServer(t *testing.T, requestURL string, httpHeaders http.Header, a ...@@ -48,6 +50,8 @@ func testEntryServer(t *testing.T, requestURL string, httpHeaders http.Header, a
w.Header().Set("Etag", testDataEtag) w.Header().Set("Etag", testDataEtag)
w.Header().Set("Cache-Control", "public") w.Header().Set("Cache-Control", "public")
w.Header().Set("Expires", "Wed, 21 Oct 2015 07:28:00 GMT") w.Header().Set("Expires", "Wed, 21 Oct 2015 07:28:00 GMT")
w.Header().Set("Date", "Wed, 21 Oct 2015 06:28:00 GMT")
w.Header().Set("Pragma", "")
http.ServeContent(w, r, "archive.txt", time.Now(), tempFile) http.ServeContent(w, r, "archive.txt", time.Now(), tempFile)
} }
...@@ -170,10 +174,16 @@ func TestOriginalCacheHeadersPreservedWithSendURL(t *testing.T) { ...@@ -170,10 +174,16 @@ func TestOriginalCacheHeadersPreservedWithSendURL(t *testing.T) {
testhelper.AssertResponseWriterHeader(t, response, testhelper.AssertResponseWriterHeader(t, response,
"Cache-Control", "Cache-Control",
"no-store") "no-cache")
testhelper.AssertResponseWriterHeader(t, response, testhelper.AssertResponseWriterHeader(t, response,
"Expires", "Expires",
"") "")
testhelper.AssertResponseWriterHeader(t, response,
"Date",
"Wed, 21 Oct 2015 05:28:00 GMT")
testhelper.AssertResponseWriterHeader(t, response,
"Pragma",
"no-cache")
} }
func TestDownloadingNonExistingFileUsingSendURL(t *testing.T) { func TestDownloadingNonExistingFileUsingSendURL(t *testing.T) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment