void ExpPayload::onHttpResponse(const HTTPDecoder& dec, const HTTPHeader& reqHeader, const HTTPHeader& respHeader, uint32_t latency) { (void) reqHeader; // check whether this content-type is to be exported if (contentTypes.find(respHeader.getContentType()) == contentTypes.end()) {return;} // check whether we expect some payload after this response if (reqHeader.getMethod() == HTTP_METHOD_HEAD) {return;} // cleanup if (openFiles.find(&dec) != openFiles.end()) { openFiles[&dec]->close(); delete openFiles[&dec]; openFiles.erase(&dec); } // get details of this content-type const ExpPayContentType& det = contentTypes[respHeader.getContentType()]; uint64_t absTS = respHeader.getTimestamp(); uint64_t relTS = getUptimeMS(); // create file-name std::stringstream ss; ss << absTS << "_" << rand() << "." << det.fileExt; // get storage file-name File file = File(det.folder, ss.str()); // add entry to stats-file *(det.stream) << absTS << "\t" << relTS << "\t" << latency << "\t" << ss.str() << std::endl; // create/open a new output stream std::ofstream* stream = new std::ofstream(); stream->open(file.getAbsolutePath().c_str()); openFiles[&dec] = stream; }
void ExpPlotLatency::onHttpResponse(const HTTPDecoder& dec, const HTTPHeader& req, const HTTPHeader& resp, uint32_t latency) { (void) dec; (void) req; append(resp.getContentType(), latency); }