Mercurial > urweb
comparison src/c/request.c @ 1788:f57983ba2a36
Get regular forms working again
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Sat, 21 Jul 2012 15:34:07 -0400 |
parents | 69daa6d70299 |
children | 77cde56d41b6 |
comparison
equal
deleted
inserted
replaced
1787:69daa6d70299 | 1788:f57983ba2a36 |
---|---|
244 char *boundary = NULL; | 244 char *boundary = NULL; |
245 size_t boundary_len = 0; | 245 size_t boundary_len = 0; |
246 char *inputs; | 246 char *inputs; |
247 const char *prefix = uw_get_url_prefix(ctx); | 247 const char *prefix = uw_get_url_prefix(ctx); |
248 char *s; | 248 char *s; |
249 int had_error = 0; | 249 int had_error = 0, is_fancy = 0; |
250 char errmsg[ERROR_BUF_LEN]; | 250 char errmsg[ERROR_BUF_LEN]; |
251 | 251 |
252 uw_reset(ctx); | 252 uw_reset(ctx); |
253 | 253 |
254 rc->queryString[0] = 0; | 254 rc->queryString[0] = 0; |
282 | 282 |
283 is_post = 1; | 283 is_post = 1; |
284 uw_isPost(ctx); | 284 uw_isPost(ctx); |
285 | 285 |
286 clen_s = uw_Basis_requestHeader(ctx, "Content-type"); | 286 clen_s = uw_Basis_requestHeader(ctx, "Content-type"); |
287 | |
288 if (!clen_s || strcasecmp(clen_s, "application/x-www-form-urlencoded")) | |
289 is_fancy = 1; | |
290 | |
287 if (clen_s && !strncasecmp(clen_s, "multipart/form-data", 19)) { | 291 if (clen_s && !strncasecmp(clen_s, "multipart/form-data", 19)) { |
288 if (strncasecmp(clen_s + 19, "; boundary=", 11)) { | 292 if (strncasecmp(clen_s + 19, "; boundary=", 11)) { |
289 log_error(logger_data, "Bad multipart boundary spec"); | 293 log_error(logger_data, "Bad multipart boundary spec"); |
290 return FAILED; | 294 return FAILED; |
291 } | 295 } |
293 boundary = clen_s + 28; | 297 boundary = clen_s + 28; |
294 boundary[0] = '-'; | 298 boundary[0] = '-'; |
295 boundary[1] = '-'; | 299 boundary[1] = '-'; |
296 boundary_len = strlen(boundary); | 300 boundary_len = strlen(boundary); |
297 } else if (clen_s) { | 301 } else if (clen_s) { |
298 uw_Basis_postBody pb = {clen_s, body}; | 302 uw_Basis_postBody pb = {clen_s, body, body_len}; |
299 uw_postBody(ctx, pb); | 303 uw_postBody(ctx, pb); |
300 } | 304 } |
301 } else if (strcmp(method, "GET")) { | 305 } else if (strcmp(method, "GET")) { |
302 log_error(logger_data, "Not ready for non-GET/POST command: %s\n", method); | 306 log_error(logger_data, "Not ready for non-GET/POST command: %s\n", method); |
303 return FAILED; | 307 return FAILED; |
428 log_error(logger_data, "%s\n", uw_error_message(ctx)); | 432 log_error(logger_data, "%s\n", uw_error_message(ctx)); |
429 return FAILED; | 433 return FAILED; |
430 } | 434 } |
431 } | 435 } |
432 } | 436 } |
433 else if (!uw_hasPostBody(ctx)) { | 437 else if (!is_fancy) { |
434 inputs = is_post ? body : query_string; | 438 inputs = is_post ? body : query_string; |
435 | 439 |
436 if (inputs) { | 440 if (inputs) { |
437 char *name, *value; | 441 char *name, *value; |
438 int len = strlen(inputs); | 442 int len = strlen(inputs); |