diff options
author | Andrey Uzunov <andrey.uzunov@gmail.com> | 2013-07-08 23:24:34 +0000 |
---|---|---|
committer | Andrey Uzunov <andrey.uzunov@gmail.com> | 2013-07-08 23:24:34 +0000 |
commit | 5946959f76fda2b28487d02d4329bc32f6ec7663 (patch) | |
tree | ce0d1a4bb7c492b0c6d475be45b8d27e835743b8 /src/microspdy | |
parent | ae343b6b9431e56647aafc973d064b160584cc66 (diff) | |
download | libmicrohttpd-5946959f76fda2b28487d02d4329bc32f6ec7663.tar.gz libmicrohttpd-5946959f76fda2b28487d02d4329bc32f6ec7663.zip |
spdy: bug fixed - breaking when no headers are provided for response
Diffstat (limited to 'src/microspdy')
-rw-r--r-- | src/microspdy/applicationlayer.c | 2 | ||||
-rw-r--r-- | src/microspdy/structures.c | 14 | ||||
-rw-r--r-- | src/microspdy/structures.h | 12 |
3 files changed, 24 insertions, 4 deletions
diff --git a/src/microspdy/applicationlayer.c b/src/microspdy/applicationlayer.c index 5be3934d..efcf2b3d 100644 --- a/src/microspdy/applicationlayer.c +++ b/src/microspdy/applicationlayer.c | |||
@@ -414,7 +414,7 @@ SPDY_build_response(int status, | |||
414 | goto free_and_fail; | 414 | goto free_and_fail; |
415 | memset(response, 0, sizeof(struct SPDY_Response)); | 415 | memset(response, 0, sizeof(struct SPDY_Response)); |
416 | 416 | ||
417 | if(NULL != headers) | 417 | if(NULL != headers && !SPDYF_name_value_is_empty(headers)) |
418 | num_hdr_containers = 2; | 418 | num_hdr_containers = 2; |
419 | 419 | ||
420 | if(NULL == (all_headers = malloc(num_hdr_containers * sizeof(struct SPDY_NameValue *)))) | 420 | if(NULL == (all_headers = malloc(num_hdr_containers * sizeof(struct SPDY_NameValue *)))) |
diff --git a/src/microspdy/structures.c b/src/microspdy/structures.c index 6430ddb2..eab7cdd6 100644 --- a/src/microspdy/structures.c +++ b/src/microspdy/structures.c | |||
@@ -27,9 +27,17 @@ | |||
27 | #include "structures.h" | 27 | #include "structures.h" |
28 | #include "internal.h" | 28 | #include "internal.h" |
29 | #include "session.h" | 29 | #include "session.h" |
30 | //TODO not for here? | ||
30 | #include <ctype.h> | 31 | #include <ctype.h> |
31 | 32 | ||
32 | 33 | ||
34 | int | ||
35 | SPDYF_name_value_is_empty(struct SPDY_NameValue *container) | ||
36 | { | ||
37 | SPDYF_ASSERT(NULL != container, "NULL is not an empty container!"); | ||
38 | return (NULL == container->name && NULL == container->value) ? SPDY_YES : SPDY_NO; | ||
39 | } | ||
40 | |||
33 | struct SPDY_NameValue * | 41 | struct SPDY_NameValue * |
34 | SPDY_name_value_create () | 42 | SPDY_name_value_create () |
35 | { | 43 | { |
@@ -65,7 +73,7 @@ SPDY_name_value_add (struct SPDY_NameValue *container, | |||
65 | return SPDY_INPUT_ERROR; | 73 | return SPDY_INPUT_ERROR; |
66 | } | 74 | } |
67 | 75 | ||
68 | if(NULL == container->name && NULL == container->value) | 76 | if(SPDYF_name_value_is_empty(container)) |
69 | { | 77 | { |
70 | //container is empty/just created | 78 | //container is empty/just created |
71 | if (NULL == (container->name = strdup (name))) | 79 | if (NULL == (container->name = strdup (name))) |
@@ -181,7 +189,7 @@ SPDY_name_value_lookup (struct SPDY_NameValue *container, | |||
181 | 189 | ||
182 | if(NULL == container || NULL == name || NULL == num_values) | 190 | if(NULL == container || NULL == name || NULL == num_values) |
183 | return NULL; | 191 | return NULL; |
184 | if(NULL == container->name && NULL == container->value) | 192 | if(SPDYF_name_value_is_empty(container)) |
185 | return NULL; | 193 | return NULL; |
186 | 194 | ||
187 | do | 195 | do |
@@ -232,7 +240,7 @@ SPDY_name_value_iterate (struct SPDY_NameValue *container, | |||
232 | return SPDY_INPUT_ERROR; | 240 | return SPDY_INPUT_ERROR; |
233 | 241 | ||
234 | //check if container is an empty struct | 242 | //check if container is an empty struct |
235 | if(NULL == container->name && NULL == container->value) | 243 | if(SPDYF_name_value_is_empty(container)) |
236 | return 0; | 244 | return 0; |
237 | 245 | ||
238 | count = 0; | 246 | count = 0; |
diff --git a/src/microspdy/structures.h b/src/microspdy/structures.h index da1e0743..45e81c3b 100644 --- a/src/microspdy/structures.h +++ b/src/microspdy/structures.h | |||
@@ -1161,6 +1161,18 @@ SPDYF_response_queue_destroy(struct SPDYF_Response_Queue *response_queue); | |||
1161 | 1161 | ||
1162 | 1162 | ||
1163 | /** | 1163 | /** |
1164 | * Checks if the container is empty, i.e. created but no values were | ||
1165 | * added to it. | ||
1166 | * | ||
1167 | * @param container | ||
1168 | * @return SPDY_YES if empty | ||
1169 | * SPDY_NO if not | ||
1170 | */ | ||
1171 | int | ||
1172 | SPDYF_name_value_is_empty(struct SPDY_NameValue *container); | ||
1173 | |||
1174 | |||
1175 | /** | ||
1164 | * Transforms raw binary decomressed stream of headers | 1176 | * Transforms raw binary decomressed stream of headers |
1165 | * into SPDY_NameValue, containing all of the headers and values. | 1177 | * into SPDY_NameValue, containing all of the headers and values. |
1166 | * | 1178 | * |