MCPcopy Create free account
hub / github.com/apache/httpd / add_trailer

Function add_trailer

modules/http2/h2_stream.c:692–742  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

690}
691
692static apr_status_t add_trailer(h2_stream *stream,
693 const char *name, size_t nlen,
694 const char *value, size_t vlen,
695 h2_hd_scratch *scratch)
696{
697 conn_rec *c = stream->session->c1;
698 const char *existing;
699
700 if (nlen == 0 || name[0] == ':') {
701 ap_log_cerror(APLOG_MARK, APLOG_DEBUG, APR_EINVAL, c,
702 H2_STRM_LOG(APLOGNO(03060), stream,
703 "pseudo header in trailer"));
704 return APR_EINVAL;
705 }
706 if (h2_ignore_req_trailer(name, nlen)) {
707 return APR_SUCCESS;
708 }
709 if (!stream->trailers_in) {
710 stream->trailers_in = apr_table_make(stream->pool, 5);
711 }
712
713 if (((nlen + vlen + 2) > scratch->max_len))
714 return APR_EINVAL;
715
716 /* We need 0-terminated strings to operate on apr_table */
717 AP_DEBUG_ASSERT(nlen < scratch->max_len);
718 memcpy(scratch->name, name, nlen);
719 scratch->name[nlen] = 0;
720 AP_DEBUG_ASSERT(vlen < scratch->max_len);
721 memcpy(scratch->value, value, vlen);
722 scratch->value[vlen] = 0;
723
724 existing = apr_table_get(stream->trailers_in, scratch->name);
725 if(existing) {
726 if (!vlen) /* not adding a 0-length value to existing */
727 return APR_SUCCESS;
728 if ((strlen(existing) + 2 + vlen + nlen + 2 > scratch->max_len)) {
729 /* "name: existing, value" is too long */
730 return APR_EINVAL;
731 }
732 apr_table_merge(stream->trailers_in, scratch->name, scratch->value);
733 }
734 else {
735 h2_util_camel_case_header(scratch->name, nlen);
736 apr_table_set(stream->trailers_in, scratch->name, scratch->value);
737 }
738 ap_log_cerror(APLOG_MARK, APLOG_TRACE2, 0, c,
739 H2_STRM_MSG(stream, "added trailer '%s: %s'"),
740 scratch->name, scratch->value);
741 return APR_SUCCESS;
742}
743
744apr_status_t h2_stream_add_header(h2_stream *stream,
745 const char *name, size_t nlen,

Callers 1

h2_stream_add_headerFunction · 0.85

Calls 2

h2_ignore_req_trailerFunction · 0.85

Tested by

no test coverage detected