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

Function extractIdFromRequest

3rdparty/libprocess/src/memory_profiler.cpp:338–360  ·  view source on GitHub ↗

TODO(bevers): Implement `http::Request::extractFromRequest (string key)` instead of having this here.

Source from the content-addressed store, hash-verified

336// TODO(bevers): Implement `http::Request::extractFromRequest<T>(string key)`
337// instead of having this here.
338Result<time_t> extractIdFromRequest(const process::http::Request& request)
339{
340 Option<string> idParameter = request.url.query.get("id");
341 if (idParameter.isNone()) {
342 return None();
343 }
344
345 // Since `strtoll()` can legitimately return any value, we have to detect
346 // errors by checking if `errno` was set during the call.
347 errno = 0;
348 char* endptr;
349 int base = 10;
350 long long parsed = std::strtoll(idParameter->c_str(), &endptr, base);
351 if (errno) {
352 return Error(strerror(errno));
353 }
354
355 if (endptr != idParameter->c_str() + idParameter->size()) {
356 return Error("Garbage after parsed id");
357 }
358
359 return parsed;
360}
361
362} // namespace {
363

Callers 3

downloadRawProfileMethod · 0.85
downloadGraphProfileMethod · 0.85

Calls 6

NoneClass · 0.85
strerrorFunction · 0.85
ErrorClass · 0.50
getMethod · 0.45
isNoneMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected