Pass through content-type for non-compressed output. (#4912)

Fixes #4911

Signed-off-by: Brian Brazil <brian.brazil@robustperception.io>
pull/4916/head
Brian Brazil 6 years ago committed by GitHub
parent bea302e061
commit d2f0f54d68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -480,7 +480,10 @@ func (s *targetScraper) scrape(ctx context.Context, w io.Writer) (string, error)
if resp.Header.Get("Content-Encoding") != "gzip" {
_, err = io.Copy(w, resp.Body)
return "", err
if err != nil {
return "", err
}
return resp.Header.Get("Content-Type"), nil
}
if s.gzipr == nil {

@ -1212,9 +1212,11 @@ func TestTargetScraperScrapeOK(t *testing.T) {
}
var buf bytes.Buffer
if _, err := ts.scrape(context.Background(), &buf); err != nil {
contentType, err := ts.scrape(context.Background(), &buf)
if err != nil {
t.Fatalf("Unexpected scrape error: %s", err)
}
require.Equal(t, "text/plain; version=0.0.4", contentType)
require.Equal(t, "metric_a 1\nmetric_b 2\n", buf.String())
}

Loading…
Cancel
Save