h2load: Use Headers instead of std::vector<std::pair<>> to store custom headers

This commit is contained in:
Tatsuhiro Tsujikawa 2014-10-22 22:53:54 +09:00
parent a9ecdca08a
commit 6933e0ef54
2 changed files with 9 additions and 7 deletions

View File

@ -833,7 +833,7 @@ int main(int argc, char **argv)
// Note that there is no processing currently to handle multiple // Note that there is no processing currently to handle multiple
// message-header fields with the same field name // message-header fields with the same field name
config.custom_headers.emplace_back(header, value); config.custom_headers.emplace_back(header, value);
util::inp_strlower(config.custom_headers.back().first); util::inp_strlower(config.custom_headers.back().name);
break; break;
} }
case 'i': { case 'i': {
@ -982,18 +982,18 @@ int main(int argc, char **argv)
}; };
for(auto& kv : config.custom_headers) { for(auto& kv : config.custom_headers) {
if(std::find(std::begin(override_hdrs), std::end(override_hdrs), kv.first) if(std::find(std::begin(override_hdrs), std::end(override_hdrs), kv.name)
!= std::end(override_hdrs)) { != std::end(override_hdrs)) {
// override header // override header
for(auto& nv : shared_nva) { for(auto& nv : shared_nva) {
if((nv.name == ":authority" && kv.first == ":host") if((nv.name == ":authority" && kv.name == ":host")
|| (nv.name == kv.first) ) { || (nv.name == kv.name) ) {
nv.value = kv.second; nv.value = kv.value;
} }
} }
} else { } else {
// add additional headers // add additional headers
shared_nva.emplace_back(kv.first, kv.second); shared_nva.push_back(kv);
} }
} }

View File

@ -43,6 +43,8 @@
#include <openssl/ssl.h> #include <openssl/ssl.h>
#include "http2.h"
namespace h2load { namespace h2load {
class Session; class Session;
@ -50,7 +52,7 @@ class Session;
struct Config { struct Config {
std::vector<std::vector<nghttp2_nv>> nva; std::vector<std::vector<nghttp2_nv>> nva;
std::vector<std::vector<const char*>> nv; std::vector<std::vector<const char*>> nv;
std::vector<std::pair<std::string, std::string>> custom_headers; nghttp2::Headers custom_headers;
std::string scheme; std::string scheme;
std::string host; std::string host;
std::string ifile; std::string ifile;