summaryrefslogtreecommitdiff
path: root/src/Request.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2008-05-13 14:15:23 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2008-05-13 14:15:23 +0000
commit386d19693bc3b06bea14f8fa606f513b6fe1ac9d (patch)
tree0137a837f6ce609ac1319b859a5333e0753f7527 /src/Request.cc
parent9d03f0d2f747c7c66a64081a7cabcf4e02c11020 (diff)
2008-05-13 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Replaced "" with static const variable A2STR::NIL. Replaced string comparison against "" with std::string::empty(). Added PROTO_* to Request class and use them as a protocol string constant. Made "started", "stopped", "completed" static const variable in AnnounceList class.
Diffstat (limited to 'src/Request.cc')
-rw-r--r--src/Request.cc25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/Request.cc b/src/Request.cc
index c34e7855..5e95708a 100644
--- a/src/Request.cc
+++ b/src/Request.cc
@@ -39,6 +39,7 @@
#include "CookieBox.h"
#include "RecoverableException.h"
#include "StringFormat.h"
+#include "A2STR.h"
#include <utility>
namespace aria2 {
@@ -47,6 +48,12 @@ const std::string Request::METHOD_GET = "GET";
const std::string Request::METHOD_HEAD = "HEAD";
+const std::string Request::PROTO_HTTP("http");
+
+const std::string Request::PROTO_HTTPS("https");
+
+const std::string Request::PROTO_FTP("ftp");
+
Request::Request():
port(0), tryCount(0),
_supportsPersistentConnection(true),
@@ -69,7 +76,7 @@ bool Request::resetUrl() {
}
bool Request::redirectUrl(const std::string& url) {
- previousUrl = "";
+ previousUrl = A2STR::NIL;
_supportsPersistentConnection = true;
return parseUrl(url);
}
@@ -84,13 +91,13 @@ bool Request::parseUrl(const std::string& url) {
}
currentUrl = tempUrl;
std::string query;
- host = "";
+ host = A2STR::NIL;
port = 0;
- dir = "";
- file = "";
- _query = "";
- _username = "";
- _password = "";
+ dir = A2STR::NIL;
+ file = A2STR::NIL;
+ _query = A2STR::NIL;
+ _username = A2STR::NIL;
+ _password = A2STR::NIL;
// find query part
std::string queryTemp;
std::string::size_type startQueryIndex = tempUrl.find("?");
@@ -126,7 +133,7 @@ bool Request::parseUrl(const std::string& url) {
std::pair<std::string, std::string> hostAndPort;
Util::split(hostAndPort, hostPart, ':');
host = hostAndPort.first;
- if(hostAndPort.second != "") {
+ if(hostAndPort.second != A2STR::NIL) {
try {
port = Util::parseInt(hostAndPort.second);
} catch(RecoverableException& e) {
@@ -168,7 +175,7 @@ bool Request::isHexNumber(const char c) const
std::string Request::urlencode(const std::string& src) const
{
if(src.empty()) {
- return "";
+ return A2STR::NIL;
}
size_t lastIndex = src.size()-1;
std::string result = src+" ";