Browse Source

http_request: reset "type" strbuf before adding

Callers may pass us a strbuf which we use to record the
content-type of the response. However, we simply appended to
it rather than overwriting its contents, meaning that cruft
in the strbuf gave us a bogus type. E.g., the multiple
requests triggered by http_request could yield a type like
"text/plainapplication/x-git-receive-pack-advertisement".

Reported-by: Michael Schubert <mschub@elegosoft.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Jeff King 12 years ago committed by Junio C Hamano
parent
commit
3443db51a0
  1. 1
      http.c

1
http.c

@ -841,6 +841,7 @@ static int http_request(const char *url, struct strbuf *type, @@ -841,6 +841,7 @@ static int http_request(const char *url, struct strbuf *type,

if (type) {
char *t;
strbuf_reset(type);
curl_easy_getinfo(slot->curl, CURLINFO_CONTENT_TYPE, &t);
if (t)
strbuf_addstr(type, t);

Loading…
Cancel
Save