From 82257cee9d543b458b418374e4ea3b7c39344eb0 Mon Sep 17 00:00:00 2001 From: Brandon Liu Date: Tue, 13 Feb 2024 18:58:50 +0800 Subject: [PATCH] Change capitalization of ETag header to align with conventions [#137] (#140) --- pmtiles/server.go | 6 +++--- pmtiles/server_test.go | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pmtiles/server.go b/pmtiles/server.go index 309df28..e9fb6cd 100644 --- a/pmtiles/server.go +++ b/pmtiles/server.go @@ -296,7 +296,7 @@ func (server *Server) getTileJSON(ctx context.Context, httpHeaders map[string]st } httpHeaders["Content-Type"] = "application/json" - httpHeaders["Etag"] = generateEtag(tilejsonBytes) + httpHeaders["ETag"] = generateEtag(tilejsonBytes) return 200, httpHeaders, tilejsonBytes } @@ -313,7 +313,7 @@ func (server *Server) getMetadata(ctx context.Context, httpHeaders map[string]st } httpHeaders["Content-Type"] = "application/json" - httpHeaders["Etag"] = generateEtag(metadataBytes) + httpHeaders["ETag"] = generateEtag(metadataBytes) return 200, httpHeaders, metadataBytes } func (server *Server) getTile(ctx context.Context, httpHeaders map[string]string, name string, z uint8, x uint32, y uint32, ext string) (int, map[string]string, []byte) { @@ -396,7 +396,7 @@ func (server *Server) getTileAttempt(ctx context.Context, httpHeaders map[string return 500, httpHeaders, []byte("I/O error"), "" } - httpHeaders["Etag"] = generateEtag(b) + httpHeaders["ETag"] = generateEtag(b) if headerVal, ok := headerContentType(header); ok { httpHeaders["Content-Type"] = headerVal } diff --git a/pmtiles/server_test.go b/pmtiles/server_test.go index 191d362..c12725f 100644 --- a/pmtiles/server_test.go +++ b/pmtiles/server_test.go @@ -401,16 +401,16 @@ func TestEtagResponsesFromTile(t *testing.T) { assert.Equal(t, 204, statusCode) // 204's have no etag - assert.Equal(t, "", headers311v1["Etag"]) - assert.Equal(t, "", headers311v2["Etag"]) + assert.Equal(t, "", headers311v1["ETag"]) + assert.Equal(t, "", headers311v2["ETag"]) // 000 and 311 didn't change - assert.Equal(t, headers000v1["Etag"], headers000v2["Etag"]) + assert.Equal(t, headers000v1["ETag"], headers000v2["ETag"]) // 412 did change - assert.NotEqual(t, headers412v1["Etag"], headers412v2["Etag"]) + assert.NotEqual(t, headers412v1["ETag"], headers412v2["ETag"]) // all are different - assert.NotEqual(t, headers000v1["Etag"], headers311v1["Etag"]) - assert.NotEqual(t, headers000v1["Etag"], headers412v1["Etag"]) + assert.NotEqual(t, headers000v1["ETag"], headers311v1["ETag"]) + assert.NotEqual(t, headers000v1["ETag"], headers412v1["ETag"]) }