当前位置: 首页>>代码示例>>C++>>正文


C++ HTTPResponse::time方法代码示例

本文整理汇总了C++中HTTPResponse::time方法的典型用法代码示例。如果您正苦于以下问题:C++ HTTPResponse::time方法的具体用法?C++ HTTPResponse::time怎么用?C++ HTTPResponse::time使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HTTPResponse的用法示例。


在下文中一共展示了HTTPResponse::time方法的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;
}
开发者ID:derrick0714,项目名称:infer,代码行数:51,代码来源:dump_http_response.cpp

示例2: main

int main(int argc, char *argv[]) {
	options_description desc_gen("Arguments");
	desc_gen.add_options()
		("help", "display help message")
		("config-file", 
			value<string>()->default_value
				("/usr/local/etc/infer.conf"),
			"specify configuration file")
		("date", value<string>(), "the date (YYYY-mm-dd)")
	;

	positional_options_description p;
	p.add("date", 1);
	variables_map vm;
	try {
		store(command_line_parser(argc, argv).
			options(desc_gen).positional(p).run(), vm);
	}
	catch (error e) {
		cerr << e.what() << endl;
		return 1;
	}
	notify(vm);

	if (vm.count("help")) {
		cout << desc_gen << endl;
		return 0;
	}

	if (!vm.count("date")) {
		cerr << "Error: date is requred." << endl;
		cerr << desc_gen << endl;
		return 1;
	}

	struct tm _tm;
	if (strptime(vm["date"].as<string>().c_str(), "%Y-%m-%d", &_tm) == NULL) {
		cerr << "Error: invalid date: " << vm["date"].as<string>() << endl;
		return 1;
	}

	cerr << "Config file: " << vm["config-file"].as<string>().c_str() << endl;
	cerr << "Date:        " << vm["date"].as<string>().c_str() << endl;

	struct tm tm_begin, tm_end;
	memset(&tm_begin, 0, sizeof(tm_begin));
	memset(&tm_end, 0, sizeof(tm_end));

	tm_begin.tm_isdst = tm_end.tm_isdst = -1;
	tm_begin.tm_year = tm_end.tm_year = _tm.tm_year;
	tm_begin.tm_mon = tm_end.tm_mon = _tm.tm_mon;
	tm_begin.tm_mday = tm_end.tm_mday = _tm.tm_mday;
	tm_begin.tm_hour = 0;
	tm_end.tm_hour = 24;

	time_t unix_begin, unix_end;
	unix_begin = mktime(&tm_begin);
	unix_end = mktime(&tm_end);

	TimeStamp time_begin, time_end;
	time_begin.set(unix_begin, 0);
	time_end.set(unix_end, 0);

	configuration conf;
	if (!conf.load(vm["config-file"].as<string>())) {
		cerr << argv[0] << ": unable to load configuration" << endl;
		return 1;
	}
	
	string data_directory;
	if (conf.get(data_directory, "data-directory", "split_http", true)
			!= configuration::OK)
	{
		cerr << argv[0] << ": data-directory required" << endl;
		return 1;
	}

	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;
//.........这里部分代码省略.........
开发者ID:derrick0714,项目名称:infer,代码行数:101,代码来源:split_http.cpp


注:本文中的HTTPResponse::time方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。