2010-11-25 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

Made strings which are only used in comparison plain C strings.
	* src/HttpHeader.cc
	* src/HttpHeader.h
	* src/Netrc.cc
	* src/Netrc.h
	* test/HttpHeaderTest.cc
This commit is contained in:
Tatsuhiro Tsujikawa 2010-11-25 12:13:33 +00:00
parent 3a897a4f32
commit ea49e9c297
6 changed files with 30 additions and 49 deletions

View File

@ -1,3 +1,12 @@
2010-11-25 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Made strings which are only used in comparison plain C strings.
* src/HttpHeader.cc
* src/HttpHeader.h
* src/Netrc.cc
* src/Netrc.h
* test/HttpHeaderTest.cc
2010-11-24 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added white space after ',' when enumerating valid parameters.

View File

@ -52,20 +52,12 @@ const std::string HttpHeader::CONTENT_DISPOSITION("Content-Disposition");
const std::string HttpHeader::SET_COOKIE("Set-Cookie");
const std::string HttpHeader::CHUNKED("chunked");
const std::string HttpHeader::GZIP("gzip");
const std::string HttpHeader::DEFLATE("deflate");
const std::string HttpHeader::CONTENT_TYPE("Content-Type");
const std::string HttpHeader::RETRY_AFTER("Retry-After");
const std::string HttpHeader::CONNECTION("Connection");
const std::string HttpHeader::CLOSE("close");
const std::string HttpHeader::CONTENT_LENGTH("Content-Length");
const std::string HttpHeader::CONTENT_RANGE("Content-Range");
@ -74,7 +66,11 @@ const std::string HttpHeader::LAST_MODIFIED("Last-Modified");
const std::string HttpHeader::ACCEPT_ENCODING("Accept-Encoding");
const std::string HttpHeader::HTTP_1_1("HTTP/1.1");
const char HttpHeader::HTTP_1_1[] = "HTTP/1.1";
const char HttpHeader::CLOSE[] = "close";
const char HttpHeader::CHUNKED[] = "chunked";
const char HttpHeader::GZIP[] = "gzip";
const char HttpHeader::DEFLATE[] = "deflate";
HttpHeader::HttpHeader() {}
HttpHeader::~HttpHeader() {}

View File

@ -122,20 +122,12 @@ public:
static const std::string SET_COOKIE;
static const std::string CHUNKED;
static const std::string GZIP;
static const std::string DEFLATE;
static const std::string CONTENT_TYPE;
static const std::string RETRY_AFTER;
static const std::string CONNECTION;
static const std::string CLOSE;
static const std::string CONTENT_LENGTH;
static const std::string CONTENT_RANGE;
@ -144,7 +136,15 @@ public:
static const std::string ACCEPT_ENCODING;
static const std::string HTTP_1_1;
static const char HTTP_1_1[];
static const char CLOSE[];
static const char CHUNKED[];
static const char GZIP[];
static const char DEFLATE[];
};
typedef SharedHandle<HttpHeader> HttpHeaderHandle;

View File

@ -108,18 +108,6 @@ bool DefaultAuthenticator::match(const std::string& hostname) const
return true;
}
const std::string Netrc::A2_MACHINE("machine");
const std::string Netrc::A2_DEFAULT("default");
const std::string Netrc::A2_LOGIN("login");
const std::string Netrc::A2_PASSWORD("password");
const std::string Netrc::A2_ACCOUNT("account");
const std::string Netrc::A2_MACDEF("macdef");
Netrc::Netrc() {}
Netrc::~Netrc() {}
@ -169,11 +157,11 @@ void Netrc::parse(const std::string& path)
eoi = tokens.end(); iter != eoi; ++iter) {
const std::string& token = *iter;
if(state == GET_TOKEN) {
if(token == Netrc::A2_MACHINE) {
if(token == "machine") {
storeAuthenticator(authenticator);
authenticator.reset(new Authenticator());
state = SET_MACHINE;
} else if(token == Netrc::A2_DEFAULT) {
} else if(token == "default") {
storeAuthenticator(authenticator);
authenticator.reset(new DefaultAuthenticator());
} else {
@ -182,13 +170,13 @@ void Netrc::parse(const std::string& path)
(fmt("Netrc:parse error. %s encounterd where 'machine'"
" or 'default' expected.", token.c_str()));
}
if(token == Netrc::A2_LOGIN) {
if(token == "login") {
state = SET_LOGIN;
} else if(token == Netrc::A2_PASSWORD) {
} else if(token == "password") {
state = SET_PASSWORD;
} else if(token == Netrc::A2_ACCOUNT) {
} else if(token == "account") {
state = SET_ACCOUNT;
} else if(token == Netrc::A2_MACDEF) {
} else if(token == "macdef") {
state = SET_MACDEF;
}
}

View File

@ -137,18 +137,6 @@ public:
}
void addAuthenticator(const SharedHandle<Authenticator>& authenticator);
static const std::string A2_MACHINE;
static const std::string A2_DEFAULT;
static const std::string A2_LOGIN;
static const std::string A2_PASSWORD;
static const std::string A2_ACCOUNT;
static const std::string A2_MACDEF;
};
} // namespace aria2

View File

@ -93,7 +93,7 @@ void HttpHeaderTest::testClearField()
CPPUNIT_ASSERT_EQUAL(std::string(""), h.getFirst("Foo"));
CPPUNIT_ASSERT_EQUAL(200, h.getStatusCode());
CPPUNIT_ASSERT_EQUAL(HttpHeader::HTTP_1_1, h.getVersion());
CPPUNIT_ASSERT_EQUAL(std::string(HttpHeader::HTTP_1_1), h.getVersion());
}
} // namespace aria2