| 934 | } |
| 935 | |
| 936 | static apr_status_t submit_stream(h2_proxy_session *session, h2_proxy_stream *stream) |
| 937 | { |
| 938 | h2_proxy_ngheader *hd; |
| 939 | nghttp2_data_provider *pp = NULL; |
| 940 | nghttp2_data_provider provider; |
| 941 | int rv, may_have_request_body = 1; |
| 942 | apr_status_t status; |
| 943 | |
| 944 | hd = h2_proxy_util_nghd_make_req(stream->pool, stream->req); |
| 945 | |
| 946 | /* If we expect a 100-continue response, we must refrain from reading |
| 947 | any input until we get it. Reading the input will possibly trigger |
| 948 | HTTP_IN filter to generate the 100-continue itself. */ |
| 949 | if (stream->waiting_on_100 || stream->waiting_on_ping) { |
| 950 | /* make a small test if we get an EOF/EOS immediately */ |
| 951 | status = ap_get_brigade(stream->r->input_filters, stream->input, |
| 952 | AP_MODE_READBYTES, APR_NONBLOCK_READ, |
| 953 | APR_BUCKET_BUFF_SIZE); |
| 954 | may_have_request_body = APR_STATUS_IS_EAGAIN(status) |
| 955 | || (status == APR_SUCCESS |
| 956 | && !APR_BUCKET_IS_EOS(APR_BRIGADE_FIRST(stream->input))); |
| 957 | } |
| 958 | |
| 959 | if (may_have_request_body) { |
| 960 | provider.source.fd = 0; |
| 961 | provider.source.ptr = NULL; |
| 962 | provider.read_callback = stream_request_data; |
| 963 | pp = &provider; |
| 964 | } |
| 965 | |
| 966 | rv = nghttp2_submit_request(session->ngh2, NULL, |
| 967 | hd->nv, hd->nvlen, pp, stream); |
| 968 | |
| 969 | ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, stream->cfront, APLOGNO(03363) |
| 970 | "h2_proxy_session(%s): submit %s%s -> %d", |
| 971 | session->id, stream->req->authority, stream->req->path, |
| 972 | rv); |
| 973 | if (rv > 0) { |
| 974 | stream->id = rv; |
| 975 | stream->state = H2_STREAM_ST_OPEN; |
| 976 | h2_proxy_ihash_add(session->streams, stream); |
| 977 | dispatch_event(session, H2_PROXYS_EV_STREAM_SUBMITTED, rv, NULL); |
| 978 | |
| 979 | return APR_SUCCESS; |
| 980 | } |
| 981 | return APR_EGENERAL; |
| 982 | } |
| 983 | |
| 984 | static apr_status_t submit_trailers(h2_proxy_stream *stream) |
| 985 | { |
no test coverage detected