diff options
author | Glenn Strauss <gstrauss@gluelogic.com> | 2021-03-24 21:39:08 -0400 |
---|---|---|
committer | Glenn Strauss <gstrauss@gluelogic.com> | 2021-04-02 01:16:40 -0400 |
commit | dc01487ea6211337fbe632f0c8921d2efaa457eb (patch) | |
tree | 4c98f6237905fbba0c4b41b31da7eaacceecb3c8 /src/mod_auth.c | |
parent | b4310877ac50c8c0cfa032debe1ca4011385f418 (diff) | |
download | lighttpd-git-dc01487ea6211337fbe632f0c8921d2efaa457eb.tar.gz |
[multiple] use buffer_append_* aggregates
reduces the number of round-trips into some frequently-called routines
Diffstat (limited to 'src/mod_auth.c')
-rw-r--r-- | src/mod_auth.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/mod_auth.c b/src/mod_auth.c index 38ce0bf6..7cd920eb 100644 --- a/src/mod_auth.c +++ b/src/mod_auth.c @@ -720,12 +720,12 @@ static handler_t mod_auth_send_400_bad_request(request_st * const r) { static handler_t mod_auth_send_401_unauthorized_basic(request_st * const r, const buffer * const realm) { r->http_status = 401; r->handler_module = NULL; - buffer * const vb = + buffer_append_str3( http_header_response_set_ptr(r, HTTP_HEADER_WWW_AUTHENTICATE, - CONST_STR_LEN("WWW-Authenticate")); - buffer_copy_string_len(vb, CONST_STR_LEN("Basic realm=\"")); - buffer_append_string_buffer(vb, realm); - buffer_append_string_len(vb, CONST_STR_LEN("\", charset=\"UTF-8\"")); + CONST_STR_LEN("WWW-Authenticate")), + CONST_STR_LEN("Basic realm=\""), + CONST_BUF_LEN(realm), + CONST_STR_LEN("\", charset=\"UTF-8\"")); return HANDLER_FINISHED; } @@ -1133,14 +1133,15 @@ static void mod_auth_digest_www_authenticate(buffer *b, time_t cur_ts, const str buffer_clear(b); for (int i = 0; i < n; ++i) { - if (i > 0) { - buffer_append_string_len(b,CONST_STR_LEN("\r\nWWW-Authenticate: ")); - } - buffer_append_string_len(b, CONST_STR_LEN("Digest realm=\"")); - buffer_append_string_buffer(b, require->realm); - buffer_append_string_len(b, CONST_STR_LEN("\", charset=\"UTF-8\", algorithm=")); - buffer_append_string_len(b, algoname[i], algolen[i]); - buffer_append_string_len(b, CONST_STR_LEN(", nonce=\"")); + struct const_iovec iov[] = { + { CONST_STR_LEN("\r\nWWW-Authenticate: ") } + ,{ CONST_STR_LEN("Digest realm=\"") } + ,{ CONST_BUF_LEN(require->realm) } + ,{ CONST_STR_LEN("\", charset=\"UTF-8\", algorithm=") } + ,{ algoname[i], algolen[i] } + ,{ CONST_STR_LEN(", nonce=\"") } + }; + buffer_append_iovec(b, iov+(0==i), sizeof(iov)/sizeof(*iov)-(0==i)); mod_auth_append_nonce(b, cur_ts, require, algoid[i], NULL); buffer_append_string_len(b, CONST_STR_LEN("\", qop=\"auth\"")); if (nonce_stale) { |