httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jerenkra...@apache.org
Subject svn commit: r595449 - /httpd/sandbox/amsterdam/d/modules/proxy/mod_serf.c
Date Thu, 15 Nov 2007 20:45:18 GMT
Author: jerenkrantz
Date: Thu Nov 15 12:45:16 2007
New Revision: 595449

URL: http://svn.apache.org/viewvc?rev=595449&view=rev
Log:
Amsterdam sandbox: Um, serf buckets support peek, so use that!  And, implement
peek for the brigade bucket.

Suggested by: Greg

Modified:
    httpd/sandbox/amsterdam/d/modules/proxy/mod_serf.c

Modified: httpd/sandbox/amsterdam/d/modules/proxy/mod_serf.c
URL: http://svn.apache.org/viewvc/httpd/sandbox/amsterdam/d/modules/proxy/mod_serf.c?rev=595449&r1=595448&r2=595449&view=diff
==============================================================================
--- httpd/sandbox/amsterdam/d/modules/proxy/mod_serf.c (original)
+++ httpd/sandbox/amsterdam/d/modules/proxy/mod_serf.c Thu Nov 15 12:45:16 2007
@@ -414,9 +414,7 @@
     return serf_bucket_create(&serf_bucket_type_brigade, ctx->allocator, ctx);
 }
 
-static apr_status_t brigade_read(serf_bucket_t *bucket,
-                                 apr_size_t requested,
-                                 const char **data, apr_size_t *len)
+static void brigade_collapse(serf_bucket_t *bucket)
 {
     brigade_bucket_ctx_t *ctx = bucket->data;
     apr_status_t status;
@@ -431,6 +429,16 @@
         }
         ctx->last_read = 0;
     }
+}
+
+static apr_status_t brigade_read(serf_bucket_t *bucket,
+                                 apr_size_t requested,
+                                 const char **data, apr_size_t *len)
+{
+    brigade_bucket_ctx_t *ctx = bucket->data;
+    apr_status_t status;
+
+    brigade_collapse(bucket);
 
     if (APR_BRIGADE_EMPTY(ctx->bb) ||
         APR_BUCKET_IS_EOS(APR_BRIGADE_FIRST(ctx->bb)) ||
@@ -491,7 +499,19 @@
                                  const char **data,
                                  apr_size_t *len)
 {
-    return APR_ENOTIMPL;
+    brigade_bucket_ctx_t *ctx = bucket->data;
+
+    brigade_collapse(bucket);
+
+    if (APR_BRIGADE_EMPTY(ctx->bb) ||
+        APR_BUCKET_IS_EOS(APR_BRIGADE_FIRST(ctx->bb)) ||
+        AP_BUCKET_IS_EOR(APR_BRIGADE_FIRST(ctx->bb))) {
+        *len = 0;
+        return APR_EOF;
+    }
+
+    return apr_bucket_read(APR_BRIGADE_FIRST(ctx->bb), data, len,
+                           APR_BLOCK_READ);
 }
 
 static void brigade_destroy(serf_bucket_t *bucket)
@@ -581,12 +601,8 @@
         apr_bucket *b;
         serf_bucket_t *sb;
 
-        ctx->serf_bucket_status = serf_bucket_read(ctx->serf_in_bucket,
-                                                   readbytes, &data, &len);
-
-        sb = serf_bucket_simple_create(data, len, NULL, NULL,
-                                       ctx->serf_bkt_alloc);
-        serf_bucket_aggregate_prepend(ctx->serf_in_bucket, sb);
+        ctx->serf_bucket_status = serf_bucket_peek(ctx->serf_in_bucket,
+                                                   &data, &len);
 
         b = apr_bucket_transient_create(data, len, f->c->bucket_alloc);
         APR_BRIGADE_INSERT_TAIL(bb, b);



Mime
View raw message