diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2011-11-12 19:24:38 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2011-11-12 19:24:38 +0900 |
| commit | 0da2468d6b4ed4ef9f96cd3d50aa6e02da863da0 (patch) | |
| tree | 4790558d314e6ceb774a095e8144f20480017084 /src/HttpRequest.cc | |
| parent | 2e5d9b056f2cf398d8996d93a4c7fbc1fbe66221 (diff) | |
Removed strappend
Diffstat (limited to 'src/HttpRequest.cc')
| -rw-r--r-- | src/HttpRequest.cc | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/src/HttpRequest.cc b/src/HttpRequest.cc index 8d3c5937..4660d18c 100644 --- a/src/HttpRequest.cc +++ b/src/HttpRequest.cc @@ -131,7 +131,7 @@ std::string getHostText(const std::string& host, uint16_t port) { std::string hosttext = host; if(!(port == 80 || port == 443)) { - strappend(hosttext, ":", util::uitos(port)); + hosttext += fmt(":%u", port);; } return hosttext; } @@ -171,7 +171,8 @@ std::string HttpRequest::createRequest() std::string acceptTypes = "*/*"; for(std::vector<std::string>::const_iterator i = acceptTypes_.begin(), eoi = acceptTypes_.end(); i != eoi; ++i) { - strappend(acceptTypes, ",", (*i)); + acceptTypes += ","; + acceptTypes += *i; } builtinHds.push_back(std::make_pair("Accept:", acceptTypes)); if(contentEncodingEnabled_) { @@ -242,7 +243,8 @@ std::string HttpRequest::createRequest() getProtocol() == Request::PROTO_HTTPS); for(std::vector<Cookie>::const_iterator itr = cookies.begin(), eoi = cookies.end(); itr != eoi; ++itr) { - strappend(cookiesValue, (*itr).toString(), ";"); + cookiesValue += (*itr).toString(); + cookiesValue += ";"; } if(!cookiesValue.empty()) { builtinHds.push_back(std::make_pair("Cookie:", cookiesValue)); @@ -263,28 +265,34 @@ std::string HttpRequest::createRequest() } } if(j == jend) { - strappend(requestLine, (*i).first, " ", (*i).second, A2STR::CRLF); + requestLine += (*i).first; + requestLine += " "; + requestLine += (*i).second; + requestLine += "\r\n"; } } // append additional headers given by user. for(std::vector<std::string>::const_iterator i = headers_.begin(), eoi = headers_.end(); i != eoi; ++i) { - strappend(requestLine, (*i), A2STR::CRLF); + requestLine += *i; + requestLine += "\r\n"; } - requestLine += A2STR::CRLF; + requestLine += "\r\n"; return requestLine; } std::string HttpRequest::createProxyRequest() const { assert(proxyRequest_); - std::string hostport = getURIHost(); - strappend(hostport, ":", util::uitos(getPort())); - - std::string requestLine = "CONNECT "; - strappend(requestLine, hostport, " HTTP/1.1\r\n"); - strappend(requestLine, "User-Agent: ", userAgent_, "\r\n"); - strappend(requestLine, "Host: ", hostport, "\r\n"); + //std::string hostport(fmt("%s:%u", getURIHost().c_str(), getPort())); + std::string requestLine(fmt("CONNECT %s:%u HTTP/1.1\r\n" + "User-Agent: %s\r\n" + "Host: %s:%u\r\n", + getURIHost().c_str(), + getPort(), + userAgent_.c_str(), + getURIHost().c_str(), + getPort())); // TODO Is "Proxy-Connection" needed here? // if(request->isKeepAliveEnabled() || request->isPipeliningEnabled()) { // requestLine += "Proxy-Connection: Keep-Alive\r\n"; @@ -293,9 +301,12 @@ std::string HttpRequest::createProxyRequest() const // } if(!proxyRequest_->getUsername().empty()) { std::pair<std::string, std::string> auth = getProxyAuthString(); - strappend(requestLine, auth.first, " ", auth.second, A2STR::CRLF); + requestLine += auth.first; + requestLine += " "; + requestLine += auth.second; + requestLine += "\r\n"; } - requestLine += A2STR::CRLF; + requestLine += "\r\n"; return requestLine; } |
