diff options
Diffstat (limited to 'src/testcurl/daemontest_process_headers.c')
-rw-r--r-- | src/testcurl/daemontest_process_headers.c | 88 |
1 files changed, 32 insertions, 56 deletions
diff --git a/src/testcurl/daemontest_process_headers.c b/src/testcurl/daemontest_process_headers.c index 77b56306..5ab0ab1b 100644 --- a/src/testcurl/daemontest_process_headers.c +++ b/src/testcurl/daemontest_process_headers.c | |||
@@ -57,17 +57,13 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) | |||
57 | return size * nmemb; | 57 | return size * nmemb; |
58 | } | 58 | } |
59 | 59 | ||
60 | static int | 60 | static int |
61 | kv_cb(void * cls, | 61 | kv_cb (void *cls, enum MHD_ValueKind kind, const char *key, const char *value) |
62 | enum MHD_ValueKind kind, | ||
63 | const char * key, | ||
64 | const char * value) | ||
65 | { | 62 | { |
66 | if ( (0 == strcmp(key, MHD_HTTP_HEADER_HOST)) && | 63 | if ((0 == strcmp (key, MHD_HTTP_HEADER_HOST)) && |
67 | (0 == strcmp(value, "localhost:21080")) && | 64 | (0 == strcmp (value, "localhost:21080")) && (kind == MHD_HEADER_KIND)) |
68 | (kind == MHD_HEADER_KIND) ) | ||
69 | { | 65 | { |
70 | *((int*) cls) = 1; | 66 | *((int *) cls) = 1; |
71 | return MHD_NO; | 67 | return MHD_NO; |
72 | } | 68 | } |
73 | return MHD_YES; | 69 | return MHD_YES; |
@@ -97,61 +93,41 @@ ahc_echo (void *cls, | |||
97 | } | 93 | } |
98 | *unused = NULL; | 94 | *unused = NULL; |
99 | ret = 0; | 95 | ret = 0; |
100 | MHD_get_connection_values (connection, | 96 | MHD_get_connection_values (connection, MHD_HEADER_KIND, &kv_cb, &ret); |
101 | MHD_HEADER_KIND, | ||
102 | &kv_cb, | ||
103 | &ret); | ||
104 | if (ret != 1) | 97 | if (ret != 1) |
105 | abort(); | 98 | abort (); |
106 | hdr = MHD_lookup_connection_value (connection, | 99 | hdr = MHD_lookup_connection_value (connection, MHD_HEADER_KIND, "NotFound"); |
107 | MHD_HEADER_KIND, | ||
108 | "NotFound"); | ||
109 | if (hdr != NULL) | 100 | if (hdr != NULL) |
110 | abort(); | 101 | abort (); |
111 | hdr = MHD_lookup_connection_value (connection, | 102 | hdr = MHD_lookup_connection_value (connection, |
112 | MHD_HEADER_KIND, | 103 | MHD_HEADER_KIND, MHD_HTTP_HEADER_ACCEPT); |
113 | MHD_HTTP_HEADER_ACCEPT); | 104 | if ((hdr == NULL) || (0 != strcmp (hdr, "*/*"))) |
114 | if ( (hdr == NULL) || | 105 | abort (); |
115 | (0 != strcmp(hdr, "*/*")) ) | 106 | hdr = MHD_lookup_connection_value (connection, |
116 | abort(); | 107 | MHD_HEADER_KIND, MHD_HTTP_HEADER_HOST); |
117 | hdr = MHD_lookup_connection_value (connection, | 108 | if ((hdr == NULL) || (0 != strcmp (hdr, "localhost:21080"))) |
118 | MHD_HEADER_KIND, | 109 | abort (); |
119 | MHD_HTTP_HEADER_HOST); | 110 | MHD_set_connection_value (connection, |
120 | if ( (hdr == NULL) || | 111 | MHD_HEADER_KIND, "FakeHeader", "NowPresent"); |
121 | (0 != strcmp(hdr, "localhost:21080")) ) | 112 | hdr = MHD_lookup_connection_value (connection, |
122 | abort(); | 113 | MHD_HEADER_KIND, "FakeHeader"); |
123 | MHD_set_connection_value (connection, | 114 | if ((hdr == NULL) || (0 != strcmp (hdr, "NowPresent"))) |
124 | MHD_HEADER_KIND, | 115 | abort (); |
125 | "FakeHeader", | ||
126 | "NowPresent"); | ||
127 | hdr = MHD_lookup_connection_value (connection, | ||
128 | MHD_HEADER_KIND, | ||
129 | "FakeHeader"); | ||
130 | if ( (hdr == NULL) || | ||
131 | (0 != strcmp(hdr, "NowPresent")) ) | ||
132 | abort(); | ||
133 | 116 | ||
134 | response = MHD_create_response_from_data (strlen (url), | 117 | response = MHD_create_response_from_data (strlen (url), |
135 | (void *) url, MHD_NO, MHD_YES); | 118 | (void *) url, MHD_NO, MHD_YES); |
136 | MHD_add_response_header (response, | 119 | MHD_add_response_header (response, "MyHeader", "MyValue"); |
137 | "MyHeader", | ||
138 | "MyValue"); | ||
139 | hdr = MHD_get_response_header (response, "MyHeader"); | 120 | hdr = MHD_get_response_header (response, "MyHeader"); |
140 | if (0 != strcmp ("MyValue", hdr)) | 121 | if (0 != strcmp ("MyValue", hdr)) |
141 | abort(); | 122 | abort (); |
142 | MHD_add_response_header (response, | 123 | MHD_add_response_header (response, "MyHeader", "MyValueToo"); |
143 | "MyHeader", | 124 | if (MHD_YES != MHD_del_response_header (response, "MyHeader", "MyValue")) |
144 | "MyValueToo"); | 125 | abort (); |
145 | if (MHD_YES != | ||
146 | MHD_del_response_header (response, | ||
147 | "MyHeader", | ||
148 | "MyValue")) | ||
149 | abort(); | ||
150 | hdr = MHD_get_response_header (response, "MyHeader"); | 126 | hdr = MHD_get_response_header (response, "MyHeader"); |
151 | if (0 != strcmp ("MyValueToo", hdr)) | 127 | if (0 != strcmp ("MyValueToo", hdr)) |
152 | abort(); | 128 | abort (); |
153 | if (1 != MHD_get_response_headers (response, NULL, NULL)) | 129 | if (1 != MHD_get_response_headers (response, NULL, NULL)) |
154 | abort(); | 130 | abort (); |
155 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); | 131 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); |
156 | MHD_destroy_response (response); | 132 | MHD_destroy_response (response); |
157 | if (ret == MHD_NO) | 133 | if (ret == MHD_NO) |
@@ -297,8 +273,8 @@ testExternalGet () | |||
297 | curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); | 273 | curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); |
298 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 15L); | 274 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 15L); |
299 | /* NOTE: use of CONNECTTIMEOUT without also | 275 | /* NOTE: use of CONNECTTIMEOUT without also |
300 | setting NOSIGNAL results in really weird | 276 | setting NOSIGNAL results in really weird |
301 | crashes on my system! */ | 277 | crashes on my system! */ |
302 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1); | 278 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1); |
303 | 279 | ||
304 | 280 | ||