本文整理汇总了C++中HTTPResponse::reason方法的典型用法代码示例。如果您正苦于以下问题:C++ HTTPResponse::reason方法的具体用法?C++ HTTPResponse::reason怎么用?C++ HTTPResponse::reason使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTTPResponse
的用法示例。
在下文中一共展示了HTTPResponse::reason方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: printHTTPResponseRecord
void printHTTPResponseRecord(const HTTPResponse &record) {
static size_t index;
static bool match;
/* -cA (client address) option. */
if (clientAddressRanges.size() > 0) {
match = false;
for (index = 0; index < clientAddressRanges.size(); ++index) {
if (record.destination_ip() >= clientAddressRanges[index].first &&
record.destination_ip() <= clientAddressRanges[index].second) {
match = true;
break;
}
}
if (!match) {
return;
}
}
/* -sA (server address) option. */
if (serverAddressRanges.size() > 0) {
match = false;
for (index = 0; index < serverAddressRanges.size(); ++index) {
if (record.source_ip() >= serverAddressRanges[index].first &&
record.source_ip() <= serverAddressRanges[index].second) {
match = true;
break;
}
}
if (!match) {
return;
}
}
cout << left << setw(18) << "Time:"
<< getDisplayTime(record.time()) << endl
<< left << setw(18) << "Source IP:"
<< ipToText(record.source_ip()) << endl
<< left << setw(18) << "Source Port:"
<< record.source_port() << endl
<< left << setw(18) << "Destination IP:"
<< ipToText(record.destination_ip()) << endl
<< left << setw(18) << "Destination Port:"
<< record.destination_port() << endl;
cout << left << setw(18) << "HTTP Version:" << record.version() << endl
<< left << setw(18) << "Status Code:" << record.status() << ' ' << record.reason() << endl;
if (!record.response().empty()) {
cout << left << setw(18) << "Server Type:" << record.response() << endl;
}
if (!record.content_type().empty()) {
cout << left << setw(18) << "Content type:" << record.content_type() << endl;
}
cout << endl;
}
示例2: main
//.........这里部分代码省略.........
string output_directory;
if (conf.get(output_directory, "output-directory", "split_http")
!= configuration::OK)
{
cerr << argv[0] << ": output-directory required" << endl;
return 1;
}
OldHTTP http;
HTTPRequest request;
HTTPResponse response;
boost::shared_ptr<StrftimeReadEnumerator> readEnum(
new StrftimeReadEnumerator);
readEnum->init(data_directory,
"%Y/%m/%d/http_%H",
time_begin,
time_end);
if (!(*readEnum)) {
cerr << "Error: Unable to initialize read readEnumerator" << endl;
return 1;
}
EnumeratedFileReader
<FlatFileReader
<OldHTTP>,
StrftimeReadEnumerator
> reader;
ErrorStatus error_status;
error_status = reader.init(readEnum);
if (error_status != E_SUCCESS && error_status != E_EOF) {
cerr << "Error: Unable to initialize EnumeratedFileReader" << endl;
return 1;
}
boost::shared_ptr<StrftimeWriteEnumerator<HTTPRequest> >
request_enumerator(new StrftimeWriteEnumerator<HTTPRequest>(
output_directory, "%Y/%m/%d/http_request_%H"));
boost::shared_ptr<StrftimeWriteEnumerator<HTTPResponse> >
response_enumerator(new StrftimeWriteEnumerator<HTTPResponse>(
output_directory, "%Y/%m/%d/http_response_%H"));
InferFileWriter<FlatFileWriter<HTTPRequest> > request_writer(request_enumerator);
InferFileWriter<FlatFileWriter<HTTPResponse> > response_writer(response_enumerator);
while ((error_status = reader.read(http)) == E_SUCCESS) {
if (http.type() == 'q') {
request.time(http.time());
request.protocol(http.protocol());
request.raw_source_ip(http.rawSourceIP());
request.raw_destination_ip(http.rawDestinationIP());
request.raw_source_port(http.rawSourcePort());
request.raw_destination_port(http.rawDestinationPort());
request.type(http.requestType());
request.uri(http.uri());
request.version(http.version());
request.host(http.host());
request.user_agent(http.userAgent());
request.referer(http.referer());
request_writer.write(&request);
}
else {
response.time(http.time());
response.protocol(http.protocol());
response.raw_source_ip(http.rawSourceIP());
response.raw_destination_ip(http.rawDestinationIP());
response.raw_source_port(http.rawSourcePort());
response.raw_destination_port(http.rawDestinationPort());
response.version(http.version());
response.status(http.status());
response.reason(http.reason());
response.response(http.response());
response.content_type(http.contentType());
response_writer.write(&response);
}
}
if (error_status != E_EOF) {
cerr << argv[0] << ": error reading HTTP data!" << endl;
return 1;
}
if (request_writer.close() != E_SUCCESS) {
cerr << "Error closing request_writer" << endl;
return 1;
}
if (response_writer.close() != E_SUCCESS) {
cerr << "Error closing response_writer" << endl;
return 1;
}
return 0;
}