summaryrefslogtreecommitdiff
path: root/src/FileEntry.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2010-09-11 12:09:19 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2010-09-11 12:09:19 +0000
commit80edde0205f8065bca84ab7acee9f38c021864b1 (patch)
treed714d4ee84f11a4ec98af6931f1fcb7f8bded7ac /src/FileEntry.cc
parentec3bd81486d6f9b266753984f0da31f8d39fd951 (diff)
2010-09-11 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Use uri::parse instead of Request::setUri() where just URI parser is needed. * src/AbstractCommand.cc * src/AdaptiveURISelector.cc * src/DefaultBtAnnounce.cc * src/FeedbackURISelector.cc * src/FileEntry.cc * src/HttpResponseCommand.cc * src/ProtocolDetector.cc * src/Request.cc * src/RequestGroupMan.cc
Diffstat (limited to 'src/FileEntry.cc')
-rw-r--r--src/FileEntry.cc30
1 files changed, 18 insertions, 12 deletions
diff --git a/src/FileEntry.cc b/src/FileEntry.cc
index 932566c3..4a494972 100644
--- a/src/FileEntry.cc
+++ b/src/FileEntry.cc
@@ -42,6 +42,7 @@
#include "LogFactory.h"
#include "wallclock.h"
#include "a2algo.h"
+#include "uri.h"
namespace aria2 {
@@ -108,10 +109,11 @@ static OutputIterator
enumerateInFlightHosts
(InputIterator first, InputIterator last, OutputIterator out)
{
- Request r;
for(; first != last; ++first) {
- r.setUri((*first)->getUri());
- *out++ = r.getHost();
+ uri::UriStruct us;
+ if(uri::parse(us, (*first)->getUri())) {
+ *out++ = us.host;
+ }
}
return out;
}
@@ -259,11 +261,13 @@ bool FileEntry::removeRequest(const SharedHandle<Request>& request)
void FileEntry::removeURIWhoseHostnameIs(const std::string& hostname)
{
std::deque<std::string> newURIs;
- Request req;
for(std::deque<std::string>::const_iterator itr = uris_.begin(),
eoi = uris_.end(); itr != eoi; ++itr) {
- if(((*itr).find(hostname) == std::string::npos) ||
- (req.setUri(*itr) && (req.getHost() != hostname))) {
+ uri::UriStruct us;
+ if(!uri::parse(us, *itr)) {
+ continue;
+ }
+ if(us.host != hostname) {
newURIs.push_back(*itr);
}
}
@@ -271,7 +275,7 @@ void FileEntry::removeURIWhoseHostnameIs(const std::string& hostname)
logger_->debug("Removed %d duplicate hostname URIs for path=%s",
uris_.size()-newURIs.size(), getPath().c_str());
}
- uris_ = newURIs;
+ uris_.swap(newURIs);
}
void FileEntry::removeIdenticalURI(const std::string& uri)
@@ -337,11 +341,11 @@ void FileEntry::reuseUri(const std::vector<std::string>& ignore)
errorUris.begin(), errorUris.end(),
std::back_inserter(reusableURIs));
std::vector<std::string>::iterator insertionPoint = reusableURIs.begin();
- Request req;
for(std::vector<std::string>::iterator i = reusableURIs.begin(),
eoi = reusableURIs.end(); i != eoi; ++i) {
- req.setUri(*i);
- if(std::find(ignore.begin(), ignore.end(), req.getHost()) == ignore.end()) {
+ uri::UriStruct us;
+ if(uri::parse(us, *i) &&
+ std::find(ignore.begin(), ignore.end(), us.host) == ignore.end()) {
if(i != insertionPoint) {
*insertionPoint = *i;
}
@@ -429,7 +433,8 @@ size_t FileEntry::setUris(const std::vector<std::string>& uris)
bool FileEntry::addUri(const std::string& uri)
{
- if(Request().setUri(uri)) {
+ uri::UriStruct us;
+ if(uri::parse(us, uri)) {
uris_.push_back(uri);
return true;
} else {
@@ -439,7 +444,8 @@ bool FileEntry::addUri(const std::string& uri)
bool FileEntry::insertUri(const std::string& uri, size_t pos)
{
- if(Request().setUri(uri)) {
+ uri::UriStruct us;
+ if(uri::parse(us, uri)) {
pos = std::min(pos, uris_.size());
uris_.insert(uris_.begin()+pos, uri);
return true;