aboutsummaryrefslogtreecommitdiff
path: root/src/microhttpd/internal.c
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2019-05-01 22:10:38 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2019-05-01 22:12:24 +0300
commit8aa7d23219052cde065b93adf04c5ded067a1fea (patch)
treefbf947885f56dd3f3da17a330c39178291ad53a7 /src/microhttpd/internal.c
parent08ea0cc894bfdd9aeddeb8bb113514c247d2c69e (diff)
downloadlibmicrohttpd-8aa7d23219052cde065b93adf04c5ded067a1fea.tar.gz
libmicrohttpd-8aa7d23219052cde065b93adf04c5ded067a1fea.zip
Partial revert of 1b610e5b13b7b96e7b3f372c8da1ec9d840f896a.
Implemented new functions for key and value with binary zero. Significantly speedup search for key by using key size.
Diffstat (limited to 'src/microhttpd/internal.c')
-rw-r--r--src/microhttpd/internal.c47
1 files changed, 26 insertions, 21 deletions
diff --git a/src/microhttpd/internal.c b/src/microhttpd/internal.c
index 8e9e0aac..ff861545 100644
--- a/src/microhttpd/internal.c
+++ b/src/microhttpd/internal.c
@@ -190,12 +190,13 @@ MHD_parse_arguments_ (struct MHD_Connection *connection,
190 struct MHD_Daemon *daemon = connection->daemon; 190 struct MHD_Daemon *daemon = connection->daemon;
191 char *equals; 191 char *equals;
192 char *amper; 192 char *amper;
193 size_t len;
194 193
195 *num_headers = 0; 194 *num_headers = 0;
196 while ( (NULL != args) && 195 while ( (NULL != args) &&
197 ('\0' != args[0]) ) 196 ('\0' != args[0]) )
198 { 197 {
198 size_t key_len;
199 size_t value_len;
199 equals = strchr (args, '='); 200 equals = strchr (args, '=');
200 amper = strchr (args, '&'); 201 amper = strchr (args, '&');
201 if (NULL == amper) 202 if (NULL == amper)
@@ -205,11 +206,12 @@ MHD_parse_arguments_ (struct MHD_Connection *connection,
205 { 206 {
206 /* last argument, without '=' */ 207 /* last argument, without '=' */
207 MHD_unescape_plus (args); 208 MHD_unescape_plus (args);
208 daemon->unescape_callback (daemon->unescape_callback_cls, 209 key_len = daemon->unescape_callback (daemon->unescape_callback_cls,
209 connection, 210 connection,
210 args); 211 args);
211 if (MHD_YES != cb (connection, 212 if (MHD_YES != cb (connection,
212 args, 213 args,
214 key_len,
213 NULL, 215 NULL,
214 0, 216 0,
215 kind)) 217 kind))
@@ -221,17 +223,18 @@ MHD_parse_arguments_ (struct MHD_Connection *connection,
221 equals[0] = '\0'; 223 equals[0] = '\0';
222 equals++; 224 equals++;
223 MHD_unescape_plus (args); 225 MHD_unescape_plus (args);
224 daemon->unescape_callback (daemon->unescape_callback_cls, 226 key_len = daemon->unescape_callback (daemon->unescape_callback_cls,
225 connection, 227 connection,
226 args); 228 args);
227 MHD_unescape_plus (equals); 229 MHD_unescape_plus (equals);
228 len = daemon->unescape_callback (daemon->unescape_callback_cls, 230 value_len = daemon->unescape_callback (daemon->unescape_callback_cls,
229 connection, 231 connection,
230 equals); 232 equals);
231 if (MHD_YES != cb (connection, 233 if (MHD_YES != cb (connection,
232 args, 234 args,
235 key_len,
233 equals, 236 equals,
234 len, 237 value_len,
235 kind)) 238 kind))
236 return MHD_NO; 239 return MHD_NO;
237 (*num_headers)++; 240 (*num_headers)++;
@@ -245,11 +248,12 @@ MHD_parse_arguments_ (struct MHD_Connection *connection,
245 { 248 {
246 /* got 'foo&bar' or 'foo&bar=val', add key 'foo' with NULL for value */ 249 /* got 'foo&bar' or 'foo&bar=val', add key 'foo' with NULL for value */
247 MHD_unescape_plus (args); 250 MHD_unescape_plus (args);
248 daemon->unescape_callback (daemon->unescape_callback_cls, 251 key_len = daemon->unescape_callback (daemon->unescape_callback_cls,
249 connection, 252 connection,
250 args); 253 args);
251 if (MHD_YES != cb (connection, 254 if (MHD_YES != cb (connection,
252 args, 255 args,
256 key_len,
253 NULL, 257 NULL,
254 0, 258 0,
255 kind)) 259 kind))
@@ -264,17 +268,18 @@ MHD_parse_arguments_ (struct MHD_Connection *connection,
264 equals[0] = '\0'; 268 equals[0] = '\0';
265 equals++; 269 equals++;
266 MHD_unescape_plus (args); 270 MHD_unescape_plus (args);
267 daemon->unescape_callback (daemon->unescape_callback_cls, 271 key_len = daemon->unescape_callback (daemon->unescape_callback_cls,
268 connection, 272 connection,
269 args); 273 args);
270 MHD_unescape_plus (equals); 274 MHD_unescape_plus (equals);
271 len = daemon->unescape_callback (daemon->unescape_callback_cls, 275 value_len = daemon->unescape_callback (daemon->unescape_callback_cls,
272 connection, 276 connection,
273 equals); 277 equals);
274 if (MHD_YES != cb (connection, 278 if (MHD_YES != cb (connection,
275 args, 279 args,
280 key_len,
276 equals, 281 equals,
277 len, 282 value_len,
278 kind)) 283 kind))
279 return MHD_NO; 284 return MHD_NO;
280 (*num_headers)++; 285 (*num_headers)++;