Skip to content

Commit 4b8ac82

Browse files
authored
Enclose etag and IfNoneMatch header in double quotes. (#2407) (#2412)
* Enclose etag and IfNoneMatch header in double quotes. fixes #2404
1 parent 526cc2c commit 4b8ac82

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

beater/agent_config_handler.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ func agentConfigHandler(kbClient *kibana.Client, enabled bool, config *agentConf
4848

4949
query, requestErr := buildQuery(r)
5050
cfg, upstreamEtag, internalErr := fetcher.Fetch(query, requestErr)
51+
etag := fmt.Sprintf("\"%s\"", upstreamEtag)
5152

5253
var resp interface{}
5354
var state int
@@ -70,13 +71,13 @@ func agentConfigHandler(kbClient *kibana.Client, enabled bool, config *agentConf
7071
resp = nil
7172
state = http.StatusNotFound
7273
headerCacheControlVal = errHeaderCacheControl
73-
case clientEtag != "" && clientEtag == upstreamEtag:
74-
w.Header().Set(headerEtag, clientEtag)
74+
case clientEtag != "" && clientEtag == etag:
75+
w.Header().Set(headerEtag, etag)
7576
resp = nil
7677
state = http.StatusNotModified
7778
headerCacheControlVal = defaultHeaderCacheControl
7879
case upstreamEtag != "":
79-
w.Header().Set(headerEtag, upstreamEtag)
80+
w.Header().Set(headerEtag, etag)
8081
fallthrough
8182
default:
8283
resp = cfg

beater/agent_config_handler_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ var testcases = map[string]struct {
5252
},
5353
}),
5454
method: http.MethodGet,
55-
requestHeader: map[string]string{headerIfNoneMatch: "1"},
55+
requestHeader: map[string]string{headerIfNoneMatch: `"` + "1" + `"`},
5656
queryParams: map[string]string{"service.name": "opbeans-node"},
5757
respStatus: http.StatusNotModified,
5858
respCacheControlHeader: "max-age=4, must-revalidate",
59-
respEtagHeader: "1",
59+
respEtagHeader: "\"1\"",
6060
},
6161

6262
"ModifiedWithoutEtag": {
@@ -87,7 +87,7 @@ var testcases = map[string]struct {
8787
requestHeader: map[string]string{headerIfNoneMatch: "2"},
8888
queryParams: map[string]string{"service.name": "opbeans-java"},
8989
respStatus: http.StatusOK,
90-
respEtagHeader: "1",
90+
respEtagHeader: "\"1\"",
9191
respCacheControlHeader: "max-age=4, must-revalidate",
9292
respBody: true,
9393
},

changelogs/7.3.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ https://github.com/elastic/apm-server/compare/v7.2.1\...v7.3.0[View commits]
2020
[float]
2121
==== Added
2222
- Support adding transaction and span information to metrics {pull}2265[2265],{pull}2287[2287].
23-
- Initial support for remote agent configuration, requires Kibana {pull}2289[2289],{pull}2301[2301]{pull}2386[2386].
23+
- Initial support for remote agent configuration, requires Kibana {pull}2289[2289],{pull}2301[2301],{pull}2386[2386],{pull}2407[2407].
2424
- Add basic caching to remote agent configuration {pull}2337[2337].
2525
- Enable APM pipeline by default {pull}2301[2301].
2626
- Add fields required by breakdown graphs APM pipeline by default {pull}2315[2315],{pull}2397[2397].

0 commit comments

Comments
 (0)