mirror of
https://github.com/grafana/grafana.git
synced 2026-08-14 07:04:57 -05:00
Plugins: Remove connection/hop-by-hop request/response headers for call resource (#60077)
Removes request/response connection/hop headers for call resource in similar manner as Go's reverse proxy functions. Also removes Prometheus datasource custom call resource header manipulation in regards to hop-by-hop headers. Fixes #60076 Ref #58646 Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>
This commit is contained in:
co-authored by
Will Browne
parent
b58cecc788
commit
7bf7308ea5
@@ -19,37 +19,6 @@ type Resource struct {
|
||||
log log.Logger
|
||||
}
|
||||
|
||||
// Hop-by-hop headers. These are removed when sent to the backend.
|
||||
// http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html
|
||||
var hopHeaders = []string{
|
||||
"Connection",
|
||||
"Keep-Alive",
|
||||
"Proxy-Authenticate",
|
||||
"Proxy-Authorization",
|
||||
"Te", // canonicalized version of "TE"
|
||||
"Trailers",
|
||||
"Transfer-Encoding",
|
||||
"Upgrade",
|
||||
}
|
||||
|
||||
// The following headers will be removed from the request
|
||||
var stopHeaders = []string{
|
||||
"cookie",
|
||||
"Cookie",
|
||||
}
|
||||
|
||||
func delHopHeaders(header http.Header) {
|
||||
for _, h := range hopHeaders {
|
||||
header.Del(h)
|
||||
}
|
||||
}
|
||||
|
||||
func delStopHeaders(header http.Header) {
|
||||
for _, h := range stopHeaders {
|
||||
header.Del(h)
|
||||
}
|
||||
}
|
||||
|
||||
func New(
|
||||
httpClient *http.Client,
|
||||
settings backend.DataSourceInstanceSettings,
|
||||
@@ -68,9 +37,6 @@ func New(
|
||||
}
|
||||
|
||||
func (r *Resource) Execute(ctx context.Context, req *backend.CallResourceRequest) (*backend.CallResourceResponse, error) {
|
||||
delHopHeaders(req.Headers)
|
||||
delStopHeaders(req.Headers)
|
||||
|
||||
r.log.FromContext(ctx).Debug("Sending resource query", "URL", req.URL)
|
||||
resp, err := r.promClient.QueryResource(ctx, req)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user