From: Christophe Jaillet Date: Thu, 17 Dec 2015 20:36:12 +0000 (+0000) Subject: Save a few cycles in 'h2_alt_svc_parse'. X-Git-Tag: 2.5.0-alpha~2525 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fed9d9dbe01d25b5db01c6b73d4b001ad91e9436;p=thirdparty%2Fapache%2Fhttpd.git Save a few cycles in 'h2_alt_svc_parse'. Save a few bytes in the request pool if sending a 'Alt-Svc' Header. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1720646 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/http2/h2_alt_svc.c b/modules/http2/h2_alt_svc.c index dea16af7ebe..2ccea963c15 100644 --- a/modules/http2/h2_alt_svc.c +++ b/modules/http2/h2_alt_svc.c @@ -41,17 +41,18 @@ void h2_alt_svc_register_hooks(void) * - do not percent encode token values * - do not use quotation marks */ -h2_alt_svc *h2_alt_svc_parse(const char *s, apr_pool_t *pool) { +h2_alt_svc *h2_alt_svc_parse(const char *s, apr_pool_t *pool) +{ const char *sep = ap_strchr_c(s, '='); if (sep) { - const char *alpn = apr_pstrndup(pool, s, sep - s); + const char *alpn = apr_pstrmemdup(pool, s, sep - s); const char *host = NULL; int port = 0; s = sep + 1; sep = ap_strchr_c(s, ':'); /* mandatory : */ if (sep) { if (sep != s) { /* optional host */ - host = apr_pstrndup(pool, s, sep - s); + host = apr_pstrmemdup(pool, s, sep - s); } s = sep + 1; if (*s) { /* must be a port number */ @@ -120,11 +121,10 @@ static int h2_alt_svc_handler(request_rec *r) } } if (*alt_svc) { - apr_table_set(r->headers_out, "Alt-Svc", alt_svc); + apr_table_setn(r->headers_out, "Alt-Svc", alt_svc); } } } return DECLINED; } -