mirror of https://github.com/aria2/aria2
HttpRequest: Use raw non-owning pointer for cookieStorage_
parent
4803482a51
commit
a4cf50914d
|
@ -554,6 +554,11 @@ AuthConfigFactory* DownloadEngine::getAuthConfigFactory() const
|
||||||
return authConfigFactory_.get();
|
return authConfigFactory_.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CookieStorage* DownloadEngine::getCookieStorage() const
|
||||||
|
{
|
||||||
|
return cookieStorage_.get();
|
||||||
|
}
|
||||||
|
|
||||||
void DownloadEngine::setRefreshInterval(int64_t interval)
|
void DownloadEngine::setRefreshInterval(int64_t interval)
|
||||||
{
|
{
|
||||||
refreshInterval_ = std::min(static_cast<int64_t>(999), interval);
|
refreshInterval_ = std::min(static_cast<int64_t>(999), interval);
|
||||||
|
|
|
@ -133,7 +133,7 @@ private:
|
||||||
|
|
||||||
std::deque<std::unique_ptr<Command>> routineCommands_;
|
std::deque<std::unique_ptr<Command>> routineCommands_;
|
||||||
|
|
||||||
std::shared_ptr<CookieStorage> cookieStorage_;
|
std::unique_ptr<CookieStorage> cookieStorage_;
|
||||||
|
|
||||||
#ifdef ENABLE_BITTORRENT
|
#ifdef ENABLE_BITTORRENT
|
||||||
std::shared_ptr<BtRegistry> btRegistry_;
|
std::shared_ptr<BtRegistry> btRegistry_;
|
||||||
|
@ -302,10 +302,7 @@ public:
|
||||||
uint16_t port,
|
uint16_t port,
|
||||||
const std::string& username);
|
const std::string& username);
|
||||||
|
|
||||||
const std::shared_ptr<CookieStorage>& getCookieStorage() const
|
CookieStorage* getCookieStorage() const;
|
||||||
{
|
|
||||||
return cookieStorage_;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef ENABLE_BITTORRENT
|
#ifdef ENABLE_BITTORRENT
|
||||||
const std::shared_ptr<BtRegistry>& getBtRegistry() const
|
const std::shared_ptr<BtRegistry>& getBtRegistry() const
|
||||||
|
|
|
@ -61,6 +61,7 @@ HttpRequest::HttpRequest()
|
||||||
: contentEncodingEnabled_(true),
|
: contentEncodingEnabled_(true),
|
||||||
userAgent_(USER_AGENT),
|
userAgent_(USER_AGENT),
|
||||||
acceptMetalink_(false),
|
acceptMetalink_(false),
|
||||||
|
cookieStorage_(0),
|
||||||
authConfigFactory_(0),
|
authConfigFactory_(0),
|
||||||
option_(0),
|
option_(0),
|
||||||
noCache_(true),
|
noCache_(true),
|
||||||
|
@ -329,12 +330,16 @@ void HttpRequest::clearHeader()
|
||||||
headers_.clear();
|
headers_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HttpRequest::setCookieStorage
|
void HttpRequest::setCookieStorage(CookieStorage* cookieStorage)
|
||||||
(const std::shared_ptr<CookieStorage>& cookieStorage)
|
|
||||||
{
|
{
|
||||||
cookieStorage_ = cookieStorage;
|
cookieStorage_ = cookieStorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CookieStorage* HttpRequest::getCookieStorage() const
|
||||||
|
{
|
||||||
|
return cookieStorage_;
|
||||||
|
}
|
||||||
|
|
||||||
void HttpRequest::setAuthConfigFactory(AuthConfigFactory* factory)
|
void HttpRequest::setAuthConfigFactory(AuthConfigFactory* factory)
|
||||||
{
|
{
|
||||||
authConfigFactory_ = factory;
|
authConfigFactory_ = factory;
|
||||||
|
|
|
@ -74,7 +74,7 @@ private:
|
||||||
// If true, metalink content types are sent in Accept header field.
|
// If true, metalink content types are sent in Accept header field.
|
||||||
bool acceptMetalink_;
|
bool acceptMetalink_;
|
||||||
|
|
||||||
std::shared_ptr<CookieStorage> cookieStorage_;
|
CookieStorage* cookieStorage_;
|
||||||
|
|
||||||
AuthConfigFactory* authConfigFactory_;
|
AuthConfigFactory* authConfigFactory_;
|
||||||
|
|
||||||
|
@ -185,12 +185,9 @@ public:
|
||||||
acceptMetalink_ = f;
|
acceptMetalink_ = f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setCookieStorage(const std::shared_ptr<CookieStorage>& cookieStorage);
|
void setCookieStorage(CookieStorage* cookieStorage);
|
||||||
|
|
||||||
const std::shared_ptr<CookieStorage>& getCookieStorage() const
|
CookieStorage* getCookieStorage() const;
|
||||||
{
|
|
||||||
return cookieStorage_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setAuthConfigFactory(AuthConfigFactory* factory);
|
void setAuthConfigFactory(AuthConfigFactory* factory);
|
||||||
void setOption(const Option* option);
|
void setOption(const Option* option);
|
||||||
|
|
|
@ -385,9 +385,9 @@ void HttpRequestTest::testCreateRequest_with_cookie()
|
||||||
createCookie("name4", "value4", "aria2.org", false, "/archives/", true),
|
createCookie("name4", "value4", "aria2.org", false, "/archives/", true),
|
||||||
createCookie("name5", "value5", "example.org", false, "/", false)
|
createCookie("name5", "value5", "example.org", false, "/", false)
|
||||||
};
|
};
|
||||||
auto st = std::make_shared<CookieStorage>();
|
CookieStorage st;
|
||||||
for(auto c : cookies) {
|
for(auto c : cookies) {
|
||||||
CPPUNIT_ASSERT(st->store(c, 0));
|
CPPUNIT_ASSERT(st.store(c, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpRequest httpRequest;
|
HttpRequest httpRequest;
|
||||||
|
@ -396,7 +396,7 @@ void HttpRequestTest::testCreateRequest_with_cookie()
|
||||||
httpRequest.setRequest(request);
|
httpRequest.setRequest(request);
|
||||||
httpRequest.setSegment(segment);
|
httpRequest.setSegment(segment);
|
||||||
httpRequest.setFileEntry(fileEntry);
|
httpRequest.setFileEntry(fileEntry);
|
||||||
httpRequest.setCookieStorage(st);
|
httpRequest.setCookieStorage(&st);
|
||||||
httpRequest.setAuthConfigFactory(authConfigFactory_.get());
|
httpRequest.setAuthConfigFactory(authConfigFactory_.get());
|
||||||
httpRequest.setOption(option_.get());
|
httpRequest.setOption(option_.get());
|
||||||
|
|
||||||
|
|
|
@ -514,8 +514,8 @@ void HttpResponseTest::testRetrieveCookie()
|
||||||
std::shared_ptr<Request> request(new Request());
|
std::shared_ptr<Request> request(new Request());
|
||||||
request->setUri("http://www.aria2.org/archives/aria2-1.0.0.tar.bz2");
|
request->setUri("http://www.aria2.org/archives/aria2-1.0.0.tar.bz2");
|
||||||
httpRequest->setRequest(request);
|
httpRequest->setRequest(request);
|
||||||
std::shared_ptr<CookieStorage> st(new CookieStorage());
|
CookieStorage st;
|
||||||
httpRequest->setCookieStorage(st);
|
httpRequest->setCookieStorage(&st);
|
||||||
httpResponse.setHttpRequest(httpRequest);
|
httpResponse.setHttpRequest(httpRequest);
|
||||||
|
|
||||||
httpHeader->put(HttpHeader::SET_COOKIE,
|
httpHeader->put(HttpHeader::SET_COOKIE,
|
||||||
|
@ -528,10 +528,10 @@ void HttpResponseTest::testRetrieveCookie()
|
||||||
|
|
||||||
httpResponse.retrieveCookie();
|
httpResponse.retrieveCookie();
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)2, st->size());
|
CPPUNIT_ASSERT_EQUAL((size_t)2, st.size());
|
||||||
|
|
||||||
std::vector<Cookie> cookies;
|
std::vector<Cookie> cookies;
|
||||||
st->dumpCookie(std::back_inserter(cookies));
|
st.dumpCookie(std::back_inserter(cookies));
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("k2=v2"), cookies[0].toString());
|
CPPUNIT_ASSERT_EQUAL(std::string("k2=v2"), cookies[0].toString());
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("k3=v3"), cookies[1].toString());
|
CPPUNIT_ASSERT_EQUAL(std::string("k3=v3"), cookies[1].toString());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue