本文整理汇总了C++中HTTPRequest::raw_source_port方法的典型用法代码示例。如果您正苦于以下问题:C++ HTTPRequest::raw_source_port方法的具体用法?C++ HTTPRequest::raw_source_port怎么用?C++ HTTPRequest::raw_source_port使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTTPRequest
的用法示例。
在下文中一共展示了HTTPRequest::raw_source_port方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}