Skip to content

Commit

Permalink
Change capitalization of ETag header to align with conventions [#137] (
Browse files Browse the repository at this point in the history
  • Loading branch information
bdon authored Feb 13, 2024
1 parent 800168b commit 82257ce
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions pmtiles/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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) {
Expand Down Expand Up @@ -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
}
Expand Down
12 changes: 6 additions & 6 deletions pmtiles/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
}

0 comments on commit 82257ce

Please sign in to comment.