You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ic...@apache.org on 2021/10/14 09:58:37 UTC
svn commit: r1894226 - in /httpd/httpd/trunk: modules/http2/h2.h
modules/http2/h2_bucket_beam.c modules/http2/h2_c2.c
modules/http2/h2_headers.c modules/http2/h2_headers.h
test/modules/http2/test_400_push.py
Author: icing
Date: Thu Oct 14 09:58:37 2021
New Revision: 1894226
URL: http://svn.apache.org/viewvc?rev=1894226&view=rev
Log:
*) mod_http2: H2HEADER buckets have the correct lenght of zero and no
longer smuggle the contained field lengths in this field. Instead
the bytes reportded to mod_logio are counted specifically.
Modified:
httpd/httpd/trunk/modules/http2/h2.h
httpd/httpd/trunk/modules/http2/h2_bucket_beam.c
httpd/httpd/trunk/modules/http2/h2_c2.c
httpd/httpd/trunk/modules/http2/h2_headers.c
httpd/httpd/trunk/modules/http2/h2_headers.h
httpd/httpd/trunk/test/modules/http2/test_400_push.py
Modified: httpd/httpd/trunk/modules/http2/h2.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http2/h2.h?rev=1894226&r1=1894225&r2=1894226&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/http2/h2.h (original)
+++ httpd/httpd/trunk/modules/http2/h2.h Thu Oct 14 09:58:37 2021
@@ -152,7 +152,7 @@ struct h2_request {
apr_table_t *headers;
apr_time_t request_time;
- int chunked; /* iff request body needs to be forwarded as chunked */
+ unsigned int chunked : 1; /* iff request body needs to be forwarded as chunked */
apr_off_t raw_bytes; /* RAW network bytes that generated this request - if known. */
int http_status; /* Store a possible HTTP status code that gets
* defined before creating the dummy HTTP/1.1
Modified: httpd/httpd/trunk/modules/http2/h2_bucket_beam.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http2/h2_bucket_beam.c?rev=1894226&r1=1894225&r2=1894226&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/http2/h2_bucket_beam.c (original)
+++ httpd/httpd/trunk/modules/http2/h2_bucket_beam.c Thu Oct 14 09:58:37 2021
@@ -442,7 +442,6 @@ static apr_status_t append_bucket(h2_buc
APR_BUCKET_REMOVE(b);
apr_bucket_setaside(b, beam->pool);
H2_BLIST_INSERT_TAIL(&beam->buckets_to_send, b);
- *pwritten += (apr_off_t)b->length;
goto cleanup;
}
/* non meta bucket */
Modified: httpd/httpd/trunk/modules/http2/h2_c2.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http2/h2_c2.c?rev=1894226&r1=1894225&r2=1894226&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/http2/h2_c2.c (original)
+++ httpd/httpd/trunk/modules/http2/h2_c2.c Thu Oct 14 09:58:37 2021
@@ -416,16 +416,32 @@ receive:
static apr_status_t beam_out(conn_rec *c2, h2_conn_ctx_t *conn_ctx, apr_bucket_brigade* bb)
{
- apr_off_t written;
+ apr_off_t written, header_len = 0;
apr_status_t rv;
+ if (h2_c2_logio_add_bytes_out) {
+ /* mod_logio wants to report the number of bytes written in a
+ * response, including header and footer fields. Since h2 converts
+ * those during c1 processing into the HPACKed h2 HEADER frames,
+ * we need to give mod_logio something here and count just the
+ * raw lengths of all headers in the buckets. */
+ apr_bucket *b;
+ for (b = APR_BRIGADE_FIRST(bb);
+ b != APR_BRIGADE_SENTINEL(bb);
+ b = APR_BUCKET_NEXT(b)) {
+ if (H2_BUCKET_IS_HEADERS(b)) {
+ header_len += (apr_off_t)h2_bucket_headers_headers_length(b);
+ }
+ }
+ }
+
rv = h2_beam_send(conn_ctx->beam_out, c2, bb, APR_BLOCK_READ, &written);
if (APR_STATUS_IS_EAGAIN(rv)) {
rv = APR_SUCCESS;
}
if (written && h2_c2_logio_add_bytes_out) {
- h2_c2_logio_add_bytes_out(c2, written);
+ h2_c2_logio_add_bytes_out(c2, written + header_len);
}
return rv;
}
Modified: httpd/httpd/trunk/modules/http2/h2_headers.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http2/h2_headers.c?rev=1894226&r1=1894225&r2=1894226&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/http2/h2_headers.c (original)
+++ httpd/httpd/trunk/modules/http2/h2_headers.c Thu Oct 14 09:58:37 2021
@@ -64,7 +64,7 @@ apr_bucket * h2_bucket_headers_make(apr_
b = apr_bucket_shared_make(b, br, 0, 0);
b->type = &h2_bucket_type_headers;
- b->length = h2_headers_length(r);
+ b->length = 0;
return b;
}
@@ -140,6 +140,12 @@ apr_size_t h2_headers_length(h2_headers
return len;
}
+apr_size_t h2_bucket_headers_headers_length(apr_bucket *b)
+{
+ h2_headers *h = h2_bucket_headers_get(b);
+ return h? h2_headers_length(h) : 0;
+}
+
h2_headers *h2_headers_rcreate(request_rec *r, int status,
const apr_table_t *header, apr_pool_t *pool)
{
Modified: httpd/httpd/trunk/modules/http2/h2_headers.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http2/h2_headers.h?rev=1894226&r1=1894225&r2=1894226&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/http2/h2_headers.h (original)
+++ httpd/httpd/trunk/modules/http2/h2_headers.h Thu Oct 14 09:58:37 2021
@@ -77,7 +77,7 @@ h2_headers *h2_headers_clone(apr_pool_t
* @param pool the memory pool to use
*/
h2_headers *h2_headers_die(apr_status_t type,
- const struct h2_request *req, apr_pool_t *pool);
+ const struct h2_request *req, apr_pool_t *pool);
int h2_headers_are_response(h2_headers *headers);
@@ -86,4 +86,10 @@ int h2_headers_are_response(h2_headers *
*/
apr_size_t h2_headers_length(h2_headers *headers);
+/**
+ * For H2HEADER buckets, return the length of all contained header strings.
+ * For all other buckets, return 0.
+ */
+apr_size_t h2_bucket_headers_headers_length(apr_bucket *b);
+
#endif /* defined(__mod_h2__h2_headers__) */
Modified: httpd/httpd/trunk/test/modules/http2/test_400_push.py
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/test/modules/http2/test_400_push.py?rev=1894226&r1=1894225&r2=1894226&view=diff
==============================================================================
--- httpd/httpd/trunk/test/modules/http2/test_400_push.py (original)
+++ httpd/httpd/trunk/test/modules/http2/test_400_push.py Thu Oct 14 09:58:37 2021
@@ -140,7 +140,7 @@ class TestStore:
assert 0 == len(promises)
# 2 H2PushResource config trigger on GET, but not on POST
- def test_h2_400_20(self, env):
+ def test_h2_400_20(self, env, repeat):
url = env.mkurl("https", "push", "/006-push20.html")
r = env.nghttp().get(url)
assert 200 == r.response["status"]