MCPcopy Create free account
hub / github.com/apache/mesos / on_message_complete

Method on_message_complete

3rdparty/libprocess/src/decoder.hpp:442–479  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

440 }
441
442 static int on_message_complete(http_parser* p)
443 {
444 ResponseDecoder* decoder = (ResponseDecoder*) p->data;
445
446 CHECK_NOTNULL(decoder->response);
447
448 if (http::isValidStatus(decoder->parser.status_code)) {
449 decoder->response->code = decoder->parser.status_code;
450
451 decoder->response->status =
452 http::Status::string(decoder->parser.status_code);
453 } else {
454 decoder->failure = true;
455 return http_parsing::FAILURE;
456 }
457
458 // We can only provide the gzip encoding.
459 Option<std::string> encoding =
460 decoder->response->headers.get("Content-Encoding");
461 if (encoding.isSome() && encoding.get() == "gzip") {
462 Try<std::string> decompressed = gzip::decompress(decoder->response->body);
463 if (decompressed.isError()) {
464 decoder->failure = true;
465 return http_parsing::FAILURE;
466 }
467 decoder->response->body = decompressed.get();
468
469 CHECK_LE(static_cast<long>(decoder->response->body.length()),
470 std::numeric_limits<char>::max());
471
472 decoder->response->headers["Content-Length"] =
473 static_cast<char>(decoder->response->body.length());
474 }
475
476 decoder->responses.push_back(decoder->response);
477 decoder->response = nullptr;
478 return http_parsing::SUCCESS;
479 }
480
481 static int on_status(http_parser* p, const char* data, size_t length)
482 {

Callers

nothing calls this directly

Calls 6

isValidStatusFunction · 0.85
maxFunction · 0.85
decompressFunction · 0.50
getMethod · 0.45
isSomeMethod · 0.45
isErrorMethod · 0.45

Tested by

no test coverage detected