Skip to content

Commit

Permalink
Ported HttpAnalyzer to C++11
Browse files Browse the repository at this point in the history
  • Loading branch information
jpcofr committed Sep 19, 2023
1 parent 7e575cc commit 89faa0b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion Examples/HttpAnalyzer/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,13 @@ void printMethods(const HttpRequestStats& reqStatscollector)
std::vector<int> columnsWidths = {9, 5};
pcpp::TablePrinter printer(columnNames, columnsWidths);

// Copy elements to a vector
std::vector<std::pair<pcpp::HttpRequestLayer::HttpMethod, int>> map2vec(reqStatscollector.methodCount.begin(), reqStatscollector.methodCount.end());
std::sort(map2vec.begin(), map2vec.end(),
[](const std::pair<pcpp::HttpRequestLayer::HttpMethod, int>& left,
const std::pair<pcpp::HttpRequestLayer::HttpMethod, int>& right) { return left.first < right.first; });
// go over the method count table and print each method and count
for (auto iter : reqStatscollector.methodCount)
for (auto iter : map2vec)
{
std::stringstream values;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ HTTP request methods
---------------------
| Method | Count |
---------------------
| POST | 3 |
| GET | 150 |
| POST | 3 |
---------------------

Hostnames count
Expand Down

0 comments on commit 89faa0b

Please sign in to comment.