MCPcopy Create free account
hub / github.com/NatronGitHub/Natron / upgrade_message_fix

Function upgrade_message_fix

libs/qhttpserver/http-parser/test.c:2390–2425  ·  view source on GitHub ↗

Given a sequence of bytes and the number of these that we were able to * parse, verify that upgrade bodies are correct. */

Source from the content-addressed store, hash-verified

2388 * parse, verify that upgrade bodies are correct.
2389 */
2390void
2391upgrade_message_fix(char *body, const size_t nread, const size_t nmsgs, ...) {
2392 va_list ap;
2393 size_t i;
2394 size_t off = 0;
2395
2396 va_start(ap, nmsgs);
2397
2398 for (i = 0; i < nmsgs; i++) {
2399 struct message *m = va_arg(ap, struct message *);
2400
2401 off += strlen(m->raw);
2402
2403 if (m->upgrade) {
2404 off -= strlen(m->upgrade);
2405
2406 /* Check the portion of the response after its specified upgrade */
2407 if (!check_str_eq(m, "upgrade", body + off, body + nread)) {
2408 abort();
2409 }
2410
2411 /* Fix up the response so that message_eq() will verify the beginning
2412 * of the upgrade */
2413 *(body + nread + strlen(m->upgrade)) = '\0';
2414 messages[num_messages -1 ].upgrade = body + nread;
2415
2416 va_end(ap);
2417 return;
2418 }
2419 }
2420
2421 va_end(ap);
2422 printf("\n\n*** Error: expected a message with upgrade ***\n");
2423
2424 abort();
2425}
2426
2427static void
2428print_error (const char *raw, size_t error_location)

Callers 2

test_multiple3Function · 0.85
test_scanFunction · 0.85

Calls 1

check_str_eqFunction · 0.85

Tested by

no test coverage detected