| 742 | } |
| 743 | |
| 744 | apr_status_t h2_stream_add_header(h2_stream *stream, |
| 745 | const char *name, size_t nlen, |
| 746 | const char *value, size_t vlen) |
| 747 | { |
| 748 | h2_session *session = stream->session; |
| 749 | int error = 0; |
| 750 | apr_status_t status = APR_SUCCESS; |
| 751 | |
| 752 | H2_STRM_ASSERT_MAGIC(stream, H2_STRM_MAGIC_OK); |
| 753 | if (stream->response) { |
| 754 | return APR_EINVAL; |
| 755 | } |
| 756 | |
| 757 | if (name[0] == ':') { |
| 758 | if (vlen > APR_INT32_MAX || (int)vlen > session->s->limit_req_line) { |
| 759 | /* pseudo header: approximation of request line size check */ |
| 760 | if (!h2_stream_is_ready(stream)) { |
| 761 | ap_log_cerror(APLOG_MARK, APLOG_INFO, 0, session->c1, |
| 762 | H2_STRM_LOG(APLOGNO(10178), stream, |
| 763 | "Request pseudo header exceeds " |
| 764 | "LimitRequestFieldSize: %s"), name); |
| 765 | } |
| 766 | error = HTTP_REQUEST_URI_TOO_LARGE; |
| 767 | goto cleanup; |
| 768 | } |
| 769 | } |
| 770 | |
| 771 | if (session->s->limit_req_fields > 0 |
| 772 | && stream->request_headers_added > session->s->limit_req_fields) { |
| 773 | /* already over limit, count this attempt, but do not take it in */ |
| 774 | ++stream->request_headers_added; |
| 775 | } |
| 776 | else if (H2_SS_IDLE == stream->state) { |
| 777 | int was_added; |
| 778 | if (!stream->rtmp) { |
| 779 | if (H2_STREAM_CLIENT_INITIATED(stream->id)) { |
| 780 | ++stream->session->remote.emitted_count; |
| 781 | if (stream->id > stream->session->remote.emitted_max) |
| 782 | session->remote.emitted_max = stream->id; |
| 783 | } |
| 784 | stream->rtmp = h2_request_create(stream->id, stream->pool, |
| 785 | NULL, NULL, NULL, NULL, NULL); |
| 786 | } |
| 787 | status = h2_request_add_header(stream->rtmp, stream->pool, |
| 788 | name, nlen, value, vlen, |
| 789 | &session->hd_scratch, &was_added); |
| 790 | ap_log_cerror(APLOG_MARK, APLOG_TRACE2, status, session->c1, |
| 791 | H2_STRM_MSG(stream, "add_header: '%.*s: %.*s"), |
| 792 | (int)nlen, name, (int)vlen, value); |
| 793 | if (was_added) ++stream->request_headers_added; |
| 794 | } |
| 795 | else if (H2_SS_OPEN == stream->state) { |
| 796 | status = add_trailer(stream, name, nlen, value, vlen, |
| 797 | &session->hd_scratch); |
| 798 | if (!status) ++stream->request_headers_added; |
| 799 | } |
| 800 | else { |
| 801 | status = APR_EINVAL; |
no test coverage detected