summaryrefslogtreecommitdiff
path: root/src/HttpHeaderProcessor.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2008-04-21 10:48:11 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2008-04-21 10:48:11 +0000
commite1fa62e6c7ce3617b8bb72b4ffe63f505cc0fdda (patch)
tree4e68de6b8c0fe23eb681dd5937b0e4409d6dbccf /src/HttpHeaderProcessor.cc
parent3eb74629cbd0f01113bc581d486a8ec95633b4ad (diff)
2008-04-21 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Now HTTP status and version are a member variable of HttpHeader. HTTP status is processed as a string, not integer. * src/AbstractProxyResponseCommand.cc * src/HttpConnection.cc * src/HttpHeader.cc * src/HttpHeader.h * src/HttpHeaderProcessor.cc * src/HttpHeaderProcessor.h * src/HttpResponse.cc * src/HttpResponse.h * test/HttpHeaderProcessorTest.cc * test/HttpResponseTest.cc
Diffstat (limited to 'src/HttpHeaderProcessor.cc')
-rw-r--r--src/HttpHeaderProcessor.cc20
1 files changed, 6 insertions, 14 deletions
diff --git a/src/HttpHeaderProcessor.cc b/src/HttpHeaderProcessor.cc
index 254bb737..b16d7f90 100644
--- a/src/HttpHeaderProcessor.cc
+++ b/src/HttpHeaderProcessor.cc
@@ -77,7 +77,7 @@ bool HttpHeaderProcessor::eoh() const
size_t HttpHeaderProcessor::getPutBackDataLength() const
{
- std::string str = strm.str();
+ const std::string& str = strm.str();
std::string::size_type delimpos = std::string::npos;
if((delimpos = str.find("\r\n\r\n")) != std::string::npos) {
return str.size()-(delimpos+4);
@@ -93,7 +93,7 @@ void HttpHeaderProcessor::clear()
strm.str("");
}
-std::pair<std::string, HttpHeaderHandle> HttpHeaderProcessor::getHttpStatusHeader()
+SharedHandle<HttpHeader> HttpHeaderProcessor::getHttpResponseHeader()
{
strm.seekg(0, std::ios::beg);
std::string line;
@@ -102,19 +102,11 @@ std::pair<std::string, HttpHeaderHandle> HttpHeaderProcessor::getHttpStatusHeade
if(line.size() <= 12) {
throw new DlRetryEx(EX_NO_STATUS_HEADER);
}
- std::string status = line.substr(9, 3);
HttpHeaderHandle httpHeader(new HttpHeader());
- while(getline(strm, line)) {
- line = Util::trim(line);
- if(line.empty()) {
- break;
- }
- std::pair<std::string, std::string> hp;
- Util::split(hp, line, ':');
- httpHeader->put(hp.first, hp.second);
- }
-
- return std::pair<std::string, HttpHeaderHandle>(status, httpHeader);
+ httpHeader->setResponseStatus(line.substr(9, 3));
+ httpHeader->setVersion(line.substr(0, 8));
+ httpHeader->fill(strm);
+ return httpHeader;
}
std::string HttpHeaderProcessor::getHeaderString() const