From 45376c6b111316c9a4d5dd7e68ae63f80b916d44 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Wed, 1 Feb 2012 21:47:25 +0900 Subject: [PATCH] spdycat: Added host header field to SYN_STREAM. --- examples/spdycat.cc | 7 ++++++- examples/spdylay_ssl.cc | 4 +++- examples/spdylay_ssl.h | 3 ++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/examples/spdycat.cc b/examples/spdycat.cc index 1c2a602a..a915f13a 100644 --- a/examples/spdycat.cc +++ b/examples/spdycat.cc @@ -46,6 +46,7 @@ #include #include #include +#include #include #include @@ -163,10 +164,14 @@ int communicate(const std::string& host, uint16_t port, nfds_t npollfds = 1; pollfd pollfds[1]; + std::stringstream ss; + ss << host << ":" << port; + std::string hostport = ss.str(); + for(int i = 0, n = reqvec.size(); i < n; ++i) { uri::UriStruct& us = reqvec[i].us; std::string path = us.dir+us.file+us.query; - int r = sc.submit_request(path, 3); + int r = sc.submit_request(hostport, path, 3); assert(r == 0); path2req[path] = &reqvec[i]; } diff --git a/examples/spdylay_ssl.cc b/examples/spdylay_ssl.cc index aef167de..c9e327e7 100644 --- a/examples/spdylay_ssl.cc +++ b/examples/spdylay_ssl.cc @@ -104,9 +104,11 @@ int Spdylay::fd() const return fd_; } -int Spdylay::submit_request(const std::string& path, uint8_t pri) +int Spdylay::submit_request(const std::string& hostport, + const std::string& path, uint8_t pri) { const char *nv[] = { + "host", hostport.c_str(), "method", "GET", "scheme", "https", "url", path.c_str(), diff --git a/examples/spdylay_ssl.h b/examples/spdylay_ssl.h index 3ec3a6ea..431532db 100644 --- a/examples/spdylay_ssl.h +++ b/examples/spdylay_ssl.h @@ -49,7 +49,8 @@ public: bool want_read(); bool want_write(); int fd() const; - int submit_request(const std::string& path, uint8_t pri); + int submit_request(const std::string& hostport, const std::string& path, + uint8_t pri); bool would_block(int r); private: int fd_;