serf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhuij...@apache.org
Subject svn commit: r1708134 - in /serf/trunk: buckets/buckets.c buckets/bwtp_buckets.c buckets/dechunk_buckets.c buckets/deflate_buckets.c buckets/response_buckets.c serf_bucket_util.h
Date Mon, 12 Oct 2015 14:53:00 GMT
Author: rhuijben
Date: Mon Oct 12 14:52:59 2015
New Revision: 1708134

URL: http://svn.apache.org/viewvc?rev=1708134&view=rev
Log:
Provide a default bucket implementation of peek() for buckets that currently
just use a NULL function. It is safer to return that there is nothing to peek
than to segfault.

* serf-dev/dev/buckets/buckets.c
  (serf_default_peek): New function.

* serf-dev/dev/buckets/bwtp_buckets.c
  (bwtp_incoming_peek,
   serf_bucket_type_bwtp_incoming_frame): Document TODO in a safer way.

* serf-dev/dev/buckets/dechunk_buckets.c
  (serf_dechunk_peek,
   serf_bucket_type_dechunk): Document TODO in a safer way.

* serf-dev/dev/buckets/deflate_buckets.c
  (serf_deflate_peek,
   serf_bucket_type_deflate): Document TODO in a safer way.

* serf-dev/dev/buckets/response_buckets.c
  (serf_response_peek,
   serf_bucket_type_response): Document TODO in a safer way.

* serf-dev/dev/serf_bucket_util.h
  (serf_default_peek): New function.

Modified:
    serf/trunk/buckets/buckets.c
    serf/trunk/buckets/bwtp_buckets.c
    serf/trunk/buckets/dechunk_buckets.c
    serf/trunk/buckets/deflate_buckets.c
    serf/trunk/buckets/response_buckets.c
    serf/trunk/serf_bucket_util.h

Modified: serf/trunk/buckets/buckets.c
URL: http://svn.apache.org/viewvc/serf/trunk/buckets/buckets.c?rev=1708134&r1=1708133&r2=1708134&view=diff
==============================================================================
--- serf/trunk/buckets/buckets.c (original)
+++ serf/trunk/buckets/buckets.c Mon Oct 12 14:52:59 2015
@@ -112,6 +112,17 @@ serf_bucket_t *serf_default_read_bucket(
     return NULL;
 }
 
+apr_status_t serf_default_peek(
+    serf_bucket_t *bucket,
+    const char **data,
+    apr_size_t *len)
+{
+    /* State: no data available */
+    *data = "";
+    *len = 0;
+    return APR_SUCCESS;
+}
+
 
 void serf_default_destroy(serf_bucket_t *bucket)
 {

Modified: serf/trunk/buckets/bwtp_buckets.c
URL: http://svn.apache.org/viewvc/serf/trunk/buckets/bwtp_buckets.c?rev=1708134&r1=1708133&r2=1708134&view=diff
==============================================================================
--- serf/trunk/buckets/bwtp_buckets.c (original)
+++ serf/trunk/buckets/bwtp_buckets.c Mon Oct 12 14:52:59 2015
@@ -586,9 +586,6 @@ static apr_status_t bwtp_incoming_readli
     return serf_bucket_readline(ctx->body, acceptable, found, data, len);
 }
 
-/* ### need to implement */
-#define bwtp_incoming_peek NULL
-
 const serf_bucket_type_t serf_bucket_type_bwtp_incoming_frame = {
     "BWTP-INCOMING",
     bwtp_incoming_read,
@@ -596,6 +593,6 @@ const serf_bucket_type_t serf_bucket_typ
     serf_default_read_iovec,
     serf_default_read_for_sendfile,
     serf_default_read_bucket,
-    bwtp_incoming_peek,
+    serf_default_peek /* ### TODO */,
     bwtp_incoming_destroy_and_data,
 };

Modified: serf/trunk/buckets/dechunk_buckets.c
URL: http://svn.apache.org/viewvc/serf/trunk/buckets/dechunk_buckets.c?rev=1708134&r1=1708133&r2=1708134&view=diff
==============================================================================
--- serf/trunk/buckets/dechunk_buckets.c (original)
+++ serf/trunk/buckets/dechunk_buckets.c Mon Oct 12 14:52:59 2015
@@ -200,7 +200,6 @@ static apr_status_t serf_dechunk_set_con
 
 /* ### need to implement */
 #define serf_dechunk_readline NULL
-#define serf_dechunk_peek NULL
 
 const serf_bucket_type_t serf_bucket_type_dechunk = {
     "DECHUNK",
@@ -209,7 +208,7 @@ const serf_bucket_type_t serf_bucket_typ
     serf_default_read_iovec,
     serf_default_read_for_sendfile,
     serf_buckets_are_v2,
-    serf_dechunk_peek /* ### TODO */,
+    serf_default_peek /* ### TODO */,
     serf_dechunk_destroy_and_data,
     serf_default_read_bucket,
     serf_default_get_remaining,

Modified: serf/trunk/buckets/deflate_buckets.c
URL: http://svn.apache.org/viewvc/serf/trunk/buckets/deflate_buckets.c?rev=1708134&r1=1708133&r2=1708134&view=diff
==============================================================================
--- serf/trunk/buckets/deflate_buckets.c (original)
+++ serf/trunk/buckets/deflate_buckets.c Mon Oct 12 14:52:59 2015
@@ -446,7 +446,6 @@ static apr_status_t serf_deflate_set_con
 
 /* ### need to implement */
 #define serf_deflate_readline NULL
-#define serf_deflate_peek NULL
 
 const serf_bucket_type_t serf_bucket_type_deflate = {
     "DEFLATE",
@@ -455,7 +454,7 @@ const serf_bucket_type_t serf_bucket_typ
     serf_default_read_iovec,
     serf_default_read_for_sendfile,
     serf_buckets_are_v2,
-    serf_deflate_peek /* ### TODO */,
+    serf_default_peek /* ### TODO */,
     serf_deflate_destroy_and_data,
     serf_default_read_bucket,
     serf_default_get_remaining,

Modified: serf/trunk/buckets/response_buckets.c
URL: http://svn.apache.org/viewvc/serf/trunk/buckets/response_buckets.c?rev=1708134&r1=1708133&r2=1708134&view=diff
==============================================================================
--- serf/trunk/buckets/response_buckets.c (original)
+++ serf/trunk/buckets/response_buckets.c Mon Oct 12 14:52:59 2015
@@ -525,9 +525,6 @@ static apr_status_t serf_response_set_co
     return serf_bucket_set_config(ctx->stream, config);
 }
 
-/* ### need to implement */
-#define serf_response_peek NULL
-
 void serf__bucket_response_set_error_on_eof(serf_bucket_t *bucket,
                                             apr_status_t error)
 {
@@ -542,7 +539,7 @@ const serf_bucket_type_t serf_bucket_typ
     serf_default_read_iovec,
     serf_default_read_for_sendfile,
     serf_buckets_are_v2,
-    serf_response_peek /* ### TODO */,
+    serf_default_peek /* ### TODO */,
     serf_response_destroy_and_data,
     serf_default_read_bucket,
     serf_default_get_remaining,

Modified: serf/trunk/serf_bucket_util.h
URL: http://svn.apache.org/viewvc/serf/trunk/serf_bucket_util.h?rev=1708134&r1=1708133&r2=1708134&view=diff
==============================================================================
--- serf/trunk/serf_bucket_util.h (original)
+++ serf/trunk/serf_bucket_util.h Mon Oct 12 14:52:59 2015
@@ -85,6 +85,18 @@ serf_bucket_t *serf_default_read_bucket(
     const serf_bucket_type_t *type);
 
 /**
+ * Default implementation of the @see peek functionality.
+ *
+ * This function will always state that there is no data available.
+ *
+ * @since New in 1.4.
+ */
+apr_status_t serf_default_peek(
+    serf_bucket_t *bucket,
+    const char **data,
+    apr_size_t *len);
+
+/**
  * Default implementation of the @see destroy functionality.
  *
  * This function will return the @a bucket to its allcoator.



Mime
View raw message