summaryrefslogtreecommitdiff
path: root/modules/http2/h2_stream.h
diff options
context:
space:
mode:
authorStefan Eissing <icing@apache.org>2022-10-11 14:54:08 +0000
committerStefan Eissing <icing@apache.org>2022-10-11 14:54:08 +0000
commit61ebb22bf9ff55a09a452b837fdbcf67c219c9bb (patch)
tree66ff53dcf0f58fc6c880022277518dc7ae33c1c2 /modules/http2/h2_stream.h
parentac04f2ff6b6590a6091b71b8c829e9b067b0fbbb (diff)
downloadhttpd-61ebb22bf9ff55a09a452b837fdbcf67c219c9bb.tar.gz
Sync with v2.0.10 from github:
* Extensive testing in production done by Alessandro Bianchi (@alexskynet) on the v2.0.x versions for stability. Many thanks! * refactored stream response handling to reflect the different phases (response/data/trailers) more clearly and help resolving cpu busy loops. * Adding more negative tests for handling of errored responses to cover edge cases. * mod_http2: fixed handling of response where neiter an EOS nor an ERROR was received as a cause to reset the stream. * mod_proxy_http2: generating error buckets for fault response bodies, to signal failure to fron when response header were already sent. v2.0.9 -------------------------------------------------------------------------------- * Fixed a bug where errors during reponse body handling did not lead to a proper RST_STREAM. Instead processing went into an infinite loop. Extended test cases to catch this condition. v2.0.8 -------------------------------------------------------------------------------- * Delaying input setup of a stream just before processing starts. This allows any EOS indicator arriving from the client before that to take effect. Without knowing that a stream has no input, internal processing has to simulate chunked encoding. This is not wrong, but somewhat more expensive and mod_security has been reported to be allergic to seeing 'chunked' on some requests. See <https://bz.apache.org/bugzilla/show_bug.cgi?id=66282>. * mod_proxy_http2: fixed #235 by no longer forwarding 'Host:' header when request ':authority' is known. Improved test case that did not catch that the previous 'fix' was incorrect. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1904522 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'modules/http2/h2_stream.h')
-rw-r--r--modules/http2/h2_stream.h58
1 files changed, 35 insertions, 23 deletions
diff --git a/modules/http2/h2_stream.h b/modules/http2/h2_stream.h
index 5b5ef35c51..695d56ac5e 100644
--- a/modules/http2/h2_stream.h
+++ b/modules/http2/h2_stream.h
@@ -87,7 +87,7 @@ struct h2_stream {
apr_bucket_brigade *in_buffer;
int in_window_size;
apr_time_t in_last_write;
-
+
struct h2_bucket_beam *output;
apr_bucket_brigade *out_buffer;
@@ -100,7 +100,7 @@ struct h2_stream {
unsigned int output_eos : 1; /* output EOS in buffer/sent */
conn_rec *c2; /* connection processing stream */
-
+
const h2_priority *pref_priority; /* preferred priority for this stream */
apr_off_t out_frames; /* # of frames sent out */
apr_off_t out_frame_octets; /* # of RAW frame octets sent out */
@@ -109,7 +109,7 @@ struct h2_stream {
apr_off_t in_data_frames; /* # of DATA frames received */
apr_off_t in_data_octets; /* # of DATA octets (payload) received */
apr_off_t in_trailer_octets; /* # of HEADER octets (payload) received in trailers */
-
+
h2_stream_monitor *monitor; /* optional monitor for stream states */
};
@@ -121,13 +121,13 @@ struct h2_stream {
* @param id the stream identifier
* @param pool the memory pool to use for this stream
* @param session the session this stream belongs to
- * @param monitor an optional monitor to be called for events and
+ * @param monitor an optional monitor to be called for events and
* state transisitions
* @param initiated_on the id of the stream this one was initiated on (PUSH)
*
* @return the newly opened stream
*/
-h2_stream *h2_stream_create(int id, apr_pool_t *pool,
+h2_stream *h2_stream_create(int id, apr_pool_t *pool,
struct h2_session *session,
h2_stream_monitor *monitor,
int initiated_on);
@@ -138,9 +138,9 @@ h2_stream *h2_stream_create(int id, apr_pool_t *pool,
void h2_stream_destroy(h2_stream *stream);
/**
- * Setup the input for the stream.
+ * Perform any late initialization before stream starts processing.
*/
-apr_status_t h2_stream_setup_input(h2_stream *stream);
+apr_status_t h2_stream_prepare_processing(h2_stream *stream);
/*
* Set a new monitor for this stream, replacing any existing one. Can
@@ -156,6 +156,22 @@ void h2_stream_set_monitor(h2_stream *stream, h2_stream_monitor *monitor);
void h2_stream_dispatch(h2_stream *stream, h2_stream_event_t ev);
/**
+ * Determine if stream is at given state.
+ * @param stream the stream to check
+ * @param state the state to look for
+ * @return != 0 iff stream is at given state.
+ */
+int h2_stream_is_at(const h2_stream *stream, h2_stream_state_t state);
+
+/**
+ * Determine if stream is reached given state or is past this state.
+ * @param stream the stream to check
+ * @param state the state to look for
+ * @return != 0 iff stream is at or past given state.
+ */
+int h2_stream_is_at_or_past(const h2_stream *stream, h2_stream_state_t state);
+
+/**
* Cleanup references into requst processing.
*
* @param stream the stream to cleanup
@@ -170,7 +186,7 @@ apr_status_t h2_stream_in_consumed(h2_stream *stream, apr_off_t amount);
/**
* Set complete stream headers from given h2_request.
- *
+ *
* @param stream stream to write request to
* @param r the request with all the meta data
* @param eos != 0 iff stream input is closed
@@ -179,16 +195,16 @@ void h2_stream_set_request(h2_stream *stream, const h2_request *r);
/**
* Set complete stream header from given request_rec.
- *
+ *
* @param stream stream to write request to
* @param r the request with all the meta data
* @param eos != 0 iff stream input is closed
*/
-apr_status_t h2_stream_set_request_rec(h2_stream *stream,
+apr_status_t h2_stream_set_request_rec(h2_stream *stream,
request_rec *r, int eos);
/*
- * Add a HTTP/2 header (including pseudo headers) or trailer
+ * Add a HTTP/2 header (including pseudo headers) or trailer
* to the given stream, depending on stream state.
*
* @param stream stream to write the header to
@@ -200,7 +216,7 @@ apr_status_t h2_stream_set_request_rec(h2_stream *stream,
apr_status_t h2_stream_add_header(h2_stream *stream,
const char *name, size_t nlen,
const char *value, size_t vlen);
-
+
/* End the construction of request headers */
apr_status_t h2_stream_end_headers(h2_stream *stream, int eos, size_t raw_bytes);
@@ -228,24 +244,20 @@ apr_status_t h2_stream_recv_DATA(h2_stream *stream, uint8_t flags,
void h2_stream_rst(h2_stream *stream, int error_code);
/**
- * Determine if stream was closed already. This is true for
- * states H2_SS_CLOSED, H2_SS_CLEANUP. But not true
- * for H2_SS_CLOSED_L and H2_SS_CLOSED_R.
- *
- * @param stream the stream to check on
- * @return != 0 iff stream has been closed
+ * Stream input signals change. Take necessary actions.
+ * @param stream the stream to read output for
*/
-int h2_stream_was_closed(const h2_stream *stream);
+void h2_stream_on_input_change(h2_stream *stream);
/**
- * Inspect the c2 output for response(s) and data.
+ * Stream output signals change. Take necessary actions.
* @param stream the stream to read output for
*/
-apr_status_t h2_stream_read_output(h2_stream *stream);
+void h2_stream_on_output_change(h2_stream *stream);
/**
* Read a maximum number of bytes into the bucket brigade.
- *
+ *
* @param stream the stream to read from
* @param bb the brigade to append output to
* @param plen (in-/out) max. number of bytes to append and on return actual
@@ -255,7 +267,7 @@ apr_status_t h2_stream_read_output(h2_stream *stream);
* APR_EAGAIN if not data is available and end of stream has not been
* reached yet.
*/
-apr_status_t h2_stream_read_to(h2_stream *stream, apr_bucket_brigade *bb,
+apr_status_t h2_stream_read_to(h2_stream *stream, apr_bucket_brigade *bb,
apr_off_t *plen, int *peos);
/**