serf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhuij...@apache.org
Subject svn commit: r1709643 - in /serf/trunk: buckets/hpack_buckets.c serf_bucket_types.h
Date Tue, 20 Oct 2015 16:48:50 GMT
Author: rhuijben
Date: Tue Oct 20 16:48:50 2015
New Revision: 1709643

URL: http://svn.apache.org/viewvc?rev=1709643&view=rev
Log:
Fix some minor issues in the current hpack code.

* buckets/hpack_buckets.c
  (serf_bucket_hpack_getc): New function.
  (serf_bucket_hpack_do): New function.
  (hpack_int): Order declarations before expressions.

Modified:
    serf/trunk/buckets/hpack_buckets.c
    serf/trunk/serf_bucket_types.h

Modified: serf/trunk/buckets/hpack_buckets.c
URL: http://svn.apache.org/viewvc/serf/trunk/buckets/hpack_buckets.c?rev=1709643&r1=1709642&r2=1709643&view=diff
==============================================================================
--- serf/trunk/buckets/hpack_buckets.c (original)
+++ serf/trunk/buckets/hpack_buckets.c Tue Oct 20 16:48:50 2015
@@ -389,12 +389,46 @@ void serf_bucket_hpack_setx(serf_bucket_
     ctx->first = ctx->last = hi;
 }
 
+const char *serf_bucket_hpack_getc(serf_bucket_t *hpack_bucket,
+                                   const char *key)
+{
+  serf_hpack_context_t *ctx = hpack_bucket->data;
+  serf_hpack_item_t *hi;
+  apr_size_t key_len = strlen(key);
+
+  for (hi = ctx->first; hi; hi = hi->next)
+    {
+      if (key_len == hi->key_len
+          && !strncasecmp(key, hi->key, key_len))
+      {
+        return hi->value;
+      }
+    }
+
+  return NULL;
+}
+
+void serf_bucket_hpack_do(serf_bucket_t *hpack_bucket,
+                          serf_bucket_hpack_do_callback_fn_t func,
+                          void *baton)
+{
+  serf_hpack_context_t *ctx = hpack_bucket->data;
+  serf_hpack_item_t *hi;
+
+  for (hi = ctx->first; hi; hi = hi->next)
+    {
+      if (func(baton, hi->key, hi->key_len, hi->value, hi->value_len))
+        break;
+    }
+}
+
 static void hpack_int(unsigned char flags, int bits, apr_uint64_t value, char to[10], apr_size_t
*used)
 {
   unsigned char max_direct;
-  flags = flags & ~((1 << bits) - 1);
   apr_size_t u;
 
+  flags = flags & ~((1 << bits) - 1);
+
   max_direct = (unsigned char)(((apr_uint16_t)1 << bits) - 1);
 
   if (value < max_direct)

Modified: serf/trunk/serf_bucket_types.h
URL: http://svn.apache.org/viewvc/serf/trunk/serf_bucket_types.h?rev=1709643&r1=1709642&r2=1709643&view=diff
==============================================================================
--- serf/trunk/serf_bucket_types.h (original)
+++ serf/trunk/serf_bucket_types.h Tue Oct 20 16:48:50 2015
@@ -832,9 +832,9 @@ void serf_bucket_hpack_setx(serf_bucket_
                             apr_size_t value_size,
                             int value_copy);
 
-const char *serf_bucket_hpack_get(serf_bucket_t *hpack_bucket,
-                                  const char *key,
-                                  apr_size_t hey_len);
+const char *serf_bucket_hpack_getc(serf_bucket_t *hpack_bucket,
+                                   const char *key,
+                                   apr_size_t key_len);
 
 /**
  * @param baton opaque baton as passed to @see serf_bucket_hpack_do



Mime
View raw message