On Thu, Oct 8, 2015 at 1:56 PM, Yann Ylavic <ylavic....@gmail.com> wrote:
>
> So we can change that later if necessary

Something like this maybe:

Index: modules/http2/h2_util.c
===================================================================
--- modules/http2/h2_util.c    (revision 1707505)
+++ modules/http2/h2_util.c    (working copy)
@@ -215,7 +215,7 @@ static const int FILE_MOVE = 1;

 static apr_status_t last_not_included(apr_bucket_brigade *bb,
                                       apr_size_t maxlen,
-                                      int same_alloc,
+                                      int same_alloc, int meta_only,
                                       int *pfile_buckets_allowed,
                                       apr_bucket **pend)
 {
@@ -223,7 +223,7 @@ static apr_status_t last_not_included(apr_bucket_b
     apr_status_t status = APR_SUCCESS;
     int files_allowed = pfile_buckets_allowed? *pfile_buckets_allowed : 0;

-    if (maxlen > 0) {
+    if (maxlen > 0 || meta_only) {
         /* Find the bucket, up to which we reach maxlen/mem bytes */
         for (b = APR_BRIGADE_FIRST(bb);
              (b != APR_BRIGADE_SENTINEL(bb));
@@ -291,7 +291,7 @@ apr_status_t h2_util_move(apr_bucket_brigade *to,
     if (!APR_BRIGADE_EMPTY(from)) {
         apr_bucket *b, *end;

-        status = last_not_included(from, maxlen, same_alloc,
+        status = last_not_included(from, maxlen, same_alloc, 0,
                                    pfile_handles_allowed, &end);
         if (status != APR_SUCCESS) {
             return status;
@@ -419,7 +419,7 @@ apr_status_t h2_util_copy(apr_bucket_brigade *to,
     if (!APR_BRIGADE_EMPTY(from)) {
         apr_bucket *b, *end, *cpy;

-        status = last_not_included(from, maxlen, 0, 0, &end);
+        status = last_not_included(from, maxlen, 0, 0, 0, &end);
         if (status != APR_SUCCESS) {
             return status;
         }
@@ -486,7 +486,7 @@ int h2_util_has_eos(apr_bucket_brigade *bb, apr_si
 {
     apr_bucket *b, *end;

-    apr_status_t status = last_not_included(bb, len, 0, 0, &end);
+    apr_status_t status = last_not_included(bb, len, 0, 1, 0, &end);
     if (status != APR_SUCCESS) {
         return status;
     }
@@ -546,28 +546,11 @@ apr_status_t h2_util_bb_avail(apr_bucket_brigade *
     if (status != APR_SUCCESS) {
         return status;
     }
-    else if (blen == 0) {
-        /* empty brigade, does it have an EOS bucket somwhere? */
-        *plen = 0;
-        *peos = h2_util_has_eos(bb, 0);
+
+    if (blen < (apr_off_t)*plen) {
+        *plen = blen;
     }
-    else if (blen > 0) {
-        /* data in the brigade, limit the length returned. Check for EOS
-         * bucket only if we indicate data. This is required since plen == 0
-         * means "the whole brigade" for h2_util_hash_eos()
-         */
-        if (blen < (apr_off_t)*plen) {
-            *plen = blen;
-        }
-        *peos = (*plen > 0)? h2_util_has_eos(bb, *plen) : 0;
-    }
-    else if (blen < 0) {
-        /* famous SHOULD NOT HAPPEN, sinc we told apr_brigade_length to readall
-         */
-        *plen = 0;
-        *peos = h2_util_has_eos(bb, 0);
-        return APR_EINVAL;
-    }
+    *peos = h2_util_has_eos(bb, *plen);
     return APR_SUCCESS;
 }

Reply via email to