commit 5946959f76fda2b28487d02d4329bc32f6ec7663
parent ae343b6b9431e56647aafc973d064b160584cc66
Author: Andrey Uzunov <andrey.uzunov@gmail.com>
Date: Mon, 8 Jul 2013 23:24:34 +0000
spdy: bug fixed - breaking when no headers are provided for response
Diffstat:
3 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/src/microspdy/applicationlayer.c b/src/microspdy/applicationlayer.c
@@ -414,7 +414,7 @@ SPDY_build_response(int status,
goto free_and_fail;
memset(response, 0, sizeof(struct SPDY_Response));
- if(NULL != headers)
+ if(NULL != headers && !SPDYF_name_value_is_empty(headers))
num_hdr_containers = 2;
if(NULL == (all_headers = malloc(num_hdr_containers * sizeof(struct SPDY_NameValue *))))
diff --git a/src/microspdy/structures.c b/src/microspdy/structures.c
@@ -27,9 +27,17 @@
#include "structures.h"
#include "internal.h"
#include "session.h"
+//TODO not for here?
#include <ctype.h>
+int
+SPDYF_name_value_is_empty(struct SPDY_NameValue *container)
+{
+ SPDYF_ASSERT(NULL != container, "NULL is not an empty container!");
+ return (NULL == container->name && NULL == container->value) ? SPDY_YES : SPDY_NO;
+}
+
struct SPDY_NameValue *
SPDY_name_value_create ()
{
@@ -65,7 +73,7 @@ SPDY_name_value_add (struct SPDY_NameValue *container,
return SPDY_INPUT_ERROR;
}
- if(NULL == container->name && NULL == container->value)
+ if(SPDYF_name_value_is_empty(container))
{
//container is empty/just created
if (NULL == (container->name = strdup (name)))
@@ -181,7 +189,7 @@ SPDY_name_value_lookup (struct SPDY_NameValue *container,
if(NULL == container || NULL == name || NULL == num_values)
return NULL;
- if(NULL == container->name && NULL == container->value)
+ if(SPDYF_name_value_is_empty(container))
return NULL;
do
@@ -232,7 +240,7 @@ SPDY_name_value_iterate (struct SPDY_NameValue *container,
return SPDY_INPUT_ERROR;
//check if container is an empty struct
- if(NULL == container->name && NULL == container->value)
+ if(SPDYF_name_value_is_empty(container))
return 0;
count = 0;
diff --git a/src/microspdy/structures.h b/src/microspdy/structures.h
@@ -1161,6 +1161,18 @@ SPDYF_response_queue_destroy(struct SPDYF_Response_Queue *response_queue);
/**
+ * Checks if the container is empty, i.e. created but no values were
+ * added to it.
+ *
+ * @param container
+ * @return SPDY_YES if empty
+ * SPDY_NO if not
+ */
+int
+SPDYF_name_value_is_empty(struct SPDY_NameValue *container);
+
+
+/**
* Transforms raw binary decomressed stream of headers
* into SPDY_NameValue, containing all of the headers and values.
*