Removed HttpHeader::findAs{LL}Int and unused HttpResponse::{has,get}RetryAfter

pull/28/head
Tatsuhiro Tsujikawa 2012-09-26 23:58:59 +09:00
parent b9f972665b
commit 8f2030da09
7 changed files with 9 additions and 56 deletions

View File

@ -85,26 +85,6 @@ HttpHeader::equalRange(int hdKey) const
return table_.equal_range(hdKey); return table_.equal_range(hdKey);
} }
int32_t HttpHeader::findAsInt(int hdKey) const
{
const std::string& value = find(hdKey);
if(value.empty()) {
return 0;
} else {
return util::parseInt(value);
}
}
int64_t HttpHeader::findAsLLInt(int hdKey) const
{
const std::string& value = find(hdKey);
if(value.empty()) {
return 0;
} else {
return util::parseLLInt(value);
}
}
RangeHandle HttpHeader::getRange() const RangeHandle HttpHeader::getRange() const
{ {
const std::string& rangeStr = find(CONTENT_RANGE); const std::string& rangeStr = find(CONTENT_RANGE);

View File

@ -107,8 +107,6 @@ public:
std::pair<std::multimap<int, std::string>::const_iterator, std::pair<std::multimap<int, std::string>::const_iterator,
std::multimap<int, std::string>::const_iterator> std::multimap<int, std::string>::const_iterator>
equalRange(int hdKey) const; equalRange(int hdKey) const;
int32_t findAsInt(int hdKey) const;
int64_t findAsLLInt(int hdKey) const;
SharedHandle<Range> getRange() const; SharedHandle<Range> getRange() const;

View File

@ -271,16 +271,6 @@ int HttpResponse::getStatusCode() const
return httpHeader_->getStatusCode(); return httpHeader_->getStatusCode();
} }
bool HttpResponse::hasRetryAfter() const
{
return httpHeader_->defined(HttpHeader::RETRY_AFTER);
}
time_t HttpResponse::getRetryAfter() const
{
return httpHeader_->findAsInt(HttpHeader::RETRY_AFTER);
}
Time HttpResponse::getLastModifiedTime() const Time HttpResponse::getLastModifiedTime() const
{ {
return Time::parseHTTPDate(httpHeader_->find(HttpHeader::LAST_MODIFIED)); return Time::parseHTTPDate(httpHeader_->find(HttpHeader::LAST_MODIFIED));

View File

@ -124,10 +124,6 @@ public:
cuid_ = cuid; cuid_ = cuid;
} }
bool hasRetryAfter() const;
time_t getRetryAfter() const;
Time getLastModifiedTime() const; Time getLastModifiedTime() const;
bool supportsPersistentConnection() const; bool supportsPersistentConnection() const;

View File

@ -148,10 +148,13 @@ SharedHandle<HttpHeader> HttpServer::receiveRequest()
if(setupResponseRecv() < 0) { if(setupResponseRecv() < 0) {
A2_LOG_INFO("Request path is invaild. Ignore the request body."); A2_LOG_INFO("Request path is invaild. Ignore the request body.");
} }
lastContentLength_ = if(!util::parseLLIntNoThrow(lastContentLength_,
lastRequestHeader_->findAsLLInt(HttpHeader::CONTENT_LENGTH); lastRequestHeader_->
if(lastContentLength_ < 0) { find(HttpHeader::CONTENT_LENGTH)) ||
throw DL_ABORT_EX("Content-Length must be positive."); lastContentLength_ < 0) {
throw DL_ABORT_EX(fmt("Invalid Content-Length=%s",
lastRequestHeader_->
find(HttpHeader::CONTENT_LENGTH).c_str()));
} }
headerProcessor_->clear(); headerProcessor_->clear();

View File

@ -140,8 +140,8 @@ void HttpHeaderProcessorTest::testGetHttpResponseHeader()
CPPUNIT_ASSERT_EQUAL(404, header->getStatusCode()); CPPUNIT_ASSERT_EQUAL(404, header->getStatusCode());
CPPUNIT_ASSERT_EQUAL(std::string("Not Found"), header->getReasonPhrase()); CPPUNIT_ASSERT_EQUAL(std::string("Not Found"), header->getReasonPhrase());
CPPUNIT_ASSERT_EQUAL(std::string("HTTP/1.1"), header->getVersion()); CPPUNIT_ASSERT_EQUAL(std::string("HTTP/1.1"), header->getVersion());
CPPUNIT_ASSERT_EQUAL((int64_t)9187LL, CPPUNIT_ASSERT_EQUAL(std::string("9187"),
header->findAsLLInt(HttpHeader::CONTENT_LENGTH)); header->find(HttpHeader::CONTENT_LENGTH));
CPPUNIT_ASSERT_EQUAL(std::string("text/html; charset=UTF-8"), CPPUNIT_ASSERT_EQUAL(std::string("text/html; charset=UTF-8"),
header->find(HttpHeader::CONTENT_TYPE)); header->find(HttpHeader::CONTENT_TYPE));
CPPUNIT_ASSERT(!header->defined(HttpHeader::CONTENT_ENCODING)); CPPUNIT_ASSERT(!header->defined(HttpHeader::CONTENT_ENCODING));

View File

@ -48,7 +48,6 @@ class HttpResponseTest : public CppUnit::TestFixture {
CPPUNIT_TEST(testValidateResponse_bad_range); CPPUNIT_TEST(testValidateResponse_bad_range);
CPPUNIT_TEST(testValidateResponse_chunked); CPPUNIT_TEST(testValidateResponse_chunked);
CPPUNIT_TEST(testValidateResponse_withIfModifiedSince); CPPUNIT_TEST(testValidateResponse_withIfModifiedSince);
CPPUNIT_TEST(testHasRetryAfter);
CPPUNIT_TEST(testProcessRedirect); CPPUNIT_TEST(testProcessRedirect);
CPPUNIT_TEST(testRetrieveCookie); CPPUNIT_TEST(testRetrieveCookie);
CPPUNIT_TEST(testSupportsPersistentConnection); CPPUNIT_TEST(testSupportsPersistentConnection);
@ -84,7 +83,6 @@ public:
void testValidateResponse_bad_range(); void testValidateResponse_bad_range();
void testValidateResponse_chunked(); void testValidateResponse_chunked();
void testValidateResponse_withIfModifiedSince(); void testValidateResponse_withIfModifiedSince();
void testHasRetryAfter();
void testProcessRedirect(); void testProcessRedirect();
void testRetrieveCookie(); void testRetrieveCookie();
void testSupportsPersistentConnection(); void testSupportsPersistentConnection();
@ -468,18 +466,6 @@ void HttpResponseTest::testValidateResponse_withIfModifiedSince()
httpResponse.validateResponse(); httpResponse.validateResponse();
} }
void HttpResponseTest::testHasRetryAfter()
{
HttpResponse httpResponse;
SharedHandle<HttpHeader> httpHeader(new HttpHeader());
httpResponse.setHttpHeader(httpHeader);
httpHeader->put(HttpHeader::RETRY_AFTER, "60");
CPPUNIT_ASSERT(httpResponse.hasRetryAfter());
CPPUNIT_ASSERT_EQUAL((time_t)60, httpResponse.getRetryAfter());
}
void HttpResponseTest::testProcessRedirect() void HttpResponseTest::testProcessRedirect()
{ {
HttpResponse httpResponse; HttpResponse httpResponse;