diff options
author | Jeff King <peff@peff.net> | 2023-09-15 13:33:16 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2023-09-15 19:54:08 +0200 |
commit | 39fa527c8976da84cf70a9ea6b6d92a1fd9bd772 (patch) | |
tree | e5eaeecf451a22ce860dd0c4c46d18ebe89a552b /http.c | |
parent | http: handle both "h2" and "h2h3" in curl info lines (diff) | |
download | git-39fa527c8976da84cf70a9ea6b6d92a1fd9bd772.tar.xz git-39fa527c8976da84cf70a9ea6b6d92a1fd9bd772.zip |
http: factor out matching of curl http/2 trace lines
We have to parse out curl's http/2 trace lines so we can redact their
headers. We already match two different types of lines from various
vintages of curl. In preparation for adding another (which will be
slightly more complex), let's pull the matching into its own function,
rather than doing it in the middle of a conditional.
While we're doing so, let's expand the comment a bit to describe the two
matches. That probably should have been part of db30130165 (http: handle
both "h2" and "h2h3" in curl info lines, 2023-06-17), but will become
even more important as we add new types.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'http.c')
-rw-r--r-- | http.c | 23 |
1 files changed, 17 insertions, 6 deletions
@@ -620,18 +620,29 @@ static int redact_sensitive_header(struct strbuf *header, size_t offset) return ret; } +static int match_curl_h2_trace(const char *line, const char **out) +{ + /* + * curl prior to 8.1.0 gives us: + * + * h2h3 [<header-name>: <header-val>] + * + * Starting in 8.1.0, the first token became just "h2". + */ + if (skip_iprefix(line, "h2h3 [", out) || + skip_iprefix(line, "h2 [", out)) + return 1; + + return 0; +} + /* Redact headers in info */ static void redact_sensitive_info_header(struct strbuf *header) { const char *sensitive_header; - /* - * curl's h2h3 prints headers in info, e.g.: - * h2h3 [<header-name>: <header-val>] - */ if (trace_curl_redact && - (skip_iprefix(header->buf, "h2h3 [", &sensitive_header) || - skip_iprefix(header->buf, "h2 [", &sensitive_header))) { + match_curl_h2_trace(header->buf, &sensitive_header)) { if (redact_sensitive_header(header, sensitive_header - header->buf)) { /* redaction ate our closing bracket */ strbuf_addch(header, ']'); |