MCPcopy Create free account
hub / github.com/apple/foundationdb / verifyMD5

Method verifyMD5

fdbrpc/HTTP.actor.cpp:64–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62}
63
64bool Response::verifyMD5(bool fail_if_header_missing, Optional<std::string> content_sum) {
65 auto i = headers.find("Content-MD5");
66 if (i != headers.end()) {
67 // If a content sum is not provided, calculate one from the response content
68 if (!content_sum.present()) {
69 MD5_CTX sum;
70 ::MD5_Init(&sum);
71 ::MD5_Update(&sum, content.data(), content.size());
72 std::string sumBytes;
73 sumBytes.resize(16);
74 ::MD5_Final((unsigned char*)sumBytes.data(), &sum);
75 std::string sumStr = base64::encoder::from_string(sumBytes);
76 sumStr.resize(sumStr.size() - 1);
77 content_sum = sumStr;
78 }
79 return i->second == content_sum.get();
80 }
81 return !fail_if_header_missing;
82}
83
84std::string Response::toString() {
85 std::string r = format("Response Code: %d\n", code);

Calls 10

MD5_InitFunction · 0.85
MD5_UpdateFunction · 0.85
MD5_FinalFunction · 0.85
getMethod · 0.65
findMethod · 0.45
endMethod · 0.45
presentMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected