mirror of https://github.com/aria2/aria2
2010-06-12 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Renamed member variables. * src/HttpRequest.cc * src/HttpRequest.hpull/1/head
parent
c7c0ec87bf
commit
f9c77a25ec
|
@ -1,3 +1,9 @@
|
|||
2010-06-12 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Renamed member variables.
|
||||
* src/HttpRequest.cc
|
||||
* src/HttpRequest.h
|
||||
|
||||
2010-06-12 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Renamed member variables.
|
||||
|
|
|
@ -56,37 +56,38 @@ namespace aria2 {
|
|||
const std::string HttpRequest::USER_AGENT("aria2");
|
||||
|
||||
HttpRequest::HttpRequest():_contentEncodingEnabled(true),
|
||||
userAgent(USER_AGENT),
|
||||
_userAgent(USER_AGENT),
|
||||
_noCache(true),
|
||||
_acceptGzip(false)
|
||||
{}
|
||||
|
||||
void HttpRequest::setSegment(const SharedHandle<Segment>& segment)
|
||||
{
|
||||
this->segment = segment;
|
||||
_segment = segment;
|
||||
}
|
||||
|
||||
void HttpRequest::setRequest(const SharedHandle<Request>& request)
|
||||
{
|
||||
this->request = request;
|
||||
_request = request;
|
||||
}
|
||||
|
||||
off_t HttpRequest::getStartByte() const
|
||||
{
|
||||
if(segment.isNull()) {
|
||||
if(_segment.isNull()) {
|
||||
return 0;
|
||||
} else {
|
||||
return _fileEntry->gtoloff(segment->getPositionToWrite());
|
||||
return _fileEntry->gtoloff(_segment->getPositionToWrite());
|
||||
}
|
||||
}
|
||||
|
||||
off_t HttpRequest::getEndByte() const
|
||||
{
|
||||
if(segment.isNull() || request.isNull()) {
|
||||
if(_segment.isNull() || _request.isNull()) {
|
||||
return 0;
|
||||
} else {
|
||||
if(request->isPipeliningEnabled()) {
|
||||
off_t endByte = _fileEntry->gtoloff(segment->getPosition()+segment->getLength()-1);
|
||||
if(_request->isPipeliningEnabled()) {
|
||||
off_t endByte =
|
||||
_fileEntry->gtoloff(_segment->getPosition()+_segment->getLength()-1);
|
||||
return std::min(endByte, static_cast<off_t>(_fileEntry->getLength()-1));
|
||||
} else {
|
||||
return 0;
|
||||
|
@ -97,7 +98,7 @@ off_t HttpRequest::getEndByte() const
|
|||
RangeHandle HttpRequest::getRange() const
|
||||
{
|
||||
// content-length is always 0
|
||||
if(segment.isNull()) {
|
||||
if(_segment.isNull()) {
|
||||
return SharedHandle<Range>(new Range());
|
||||
} else {
|
||||
return SharedHandle<Range>(new Range(getStartByte(), getEndByte(),
|
||||
|
@ -107,7 +108,7 @@ RangeHandle HttpRequest::getRange() const
|
|||
|
||||
bool HttpRequest::isRangeSatisfied(const RangeHandle& range) const
|
||||
{
|
||||
if(segment.isNull()) {
|
||||
if(_segment.isNull()) {
|
||||
return true;
|
||||
}
|
||||
if((getStartByte() == range->getStartByte()) &&
|
||||
|
@ -132,12 +133,12 @@ static std::string getHostText(const std::string& host, uint16_t port)
|
|||
|
||||
std::string HttpRequest::createRequest()
|
||||
{
|
||||
_authConfig = _authConfigFactory->createAuthConfig(request, _option);
|
||||
std::string requestLine = request->getMethod();
|
||||
_authConfig = _authConfigFactory->createAuthConfig(_request, _option);
|
||||
std::string requestLine = _request->getMethod();
|
||||
requestLine += " ";
|
||||
if(!_proxyRequest.isNull()) {
|
||||
if(getProtocol() == Request::PROTO_FTP &&
|
||||
request->getUsername().empty() && !_authConfig.isNull()) {
|
||||
_request->getUsername().empty() && !_authConfig.isNull()) {
|
||||
// Insert user into URI, like ftp://USER@host/
|
||||
std::string uri = getCurrentURI();
|
||||
assert(uri.size() >= 6);
|
||||
|
@ -160,7 +161,7 @@ std::string HttpRequest::createRequest()
|
|||
|
||||
std::vector<std::pair<std::string, std::string> > builtinHds;
|
||||
builtinHds.reserve(20);
|
||||
builtinHds.push_back(std::make_pair("User-Agent:", userAgent));
|
||||
builtinHds.push_back(std::make_pair("User-Agent:", _userAgent));
|
||||
std::string acceptTypes = "*/*";
|
||||
for(std::vector<std::string>::const_iterator i = _acceptTypes.begin(),
|
||||
eoi = _acceptTypes.end(); i != eoi; ++i) {
|
||||
|
@ -185,21 +186,21 @@ std::string HttpRequest::createRequest()
|
|||
builtinHds.push_back(std::make_pair("Pragma:", "no-cache"));
|
||||
builtinHds.push_back(std::make_pair("Cache-Control:", "no-cache"));
|
||||
}
|
||||
if(!request->isKeepAliveEnabled() && !request->isPipeliningEnabled()) {
|
||||
if(!_request->isKeepAliveEnabled() && !_request->isPipeliningEnabled()) {
|
||||
builtinHds.push_back(std::make_pair("Connection:", "close"));
|
||||
}
|
||||
if(!segment.isNull() && segment->getLength() > 0 &&
|
||||
(request->isPipeliningEnabled() || getStartByte() > 0)) {
|
||||
if(!_segment.isNull() && _segment->getLength() > 0 &&
|
||||
(_request->isPipeliningEnabled() || getStartByte() > 0)) {
|
||||
std::string rangeHeader = "bytes=";
|
||||
rangeHeader += util::itos(getStartByte());
|
||||
rangeHeader += "-";
|
||||
if(request->isPipeliningEnabled()) {
|
||||
if(_request->isPipeliningEnabled()) {
|
||||
rangeHeader += util::itos(getEndByte());
|
||||
}
|
||||
builtinHds.push_back(std::make_pair("Range:", rangeHeader));
|
||||
}
|
||||
if(!_proxyRequest.isNull()) {
|
||||
if(request->isKeepAliveEnabled() || request->isPipeliningEnabled()) {
|
||||
if(_request->isKeepAliveEnabled() || _request->isPipeliningEnabled()) {
|
||||
builtinHds.push_back(std::make_pair("Proxy-Connection:", "Keep-Alive"));
|
||||
} else {
|
||||
builtinHds.push_back(std::make_pair("Proxy-Connection:", "close"));
|
||||
|
@ -263,7 +264,7 @@ std::string HttpRequest::createProxyRequest() const
|
|||
|
||||
std::string requestLine = "CONNECT ";
|
||||
strappend(requestLine, hostport, " HTTP/1.1\r\n");
|
||||
strappend(requestLine, "User-Agent: ", userAgent, "\r\n");
|
||||
strappend(requestLine, "User-Agent: ", _userAgent, "\r\n");
|
||||
strappend(requestLine, "Host: ", hostport, "\r\n");
|
||||
// TODO Is "Proxy-Connection" needed here?
|
||||
// if(request->isKeepAliveEnabled() || request->isPipeliningEnabled()) {
|
||||
|
|
|
@ -59,15 +59,15 @@ private:
|
|||
|
||||
static const std::string USER_AGENT;
|
||||
|
||||
SharedHandle<Request> request;
|
||||
SharedHandle<Request> _request;
|
||||
|
||||
SharedHandle<FileEntry> _fileEntry;
|
||||
|
||||
SharedHandle<Segment> segment;
|
||||
SharedHandle<Segment> _segment;
|
||||
|
||||
bool _contentEncodingEnabled;
|
||||
|
||||
std::string userAgent;
|
||||
std::string _userAgent;
|
||||
|
||||
std::vector<std::string> _headers;
|
||||
|
||||
|
@ -93,7 +93,7 @@ public:
|
|||
|
||||
const SharedHandle<Segment>& getSegment() const
|
||||
{
|
||||
return segment;
|
||||
return _segment;
|
||||
}
|
||||
|
||||
void setSegment(const SharedHandle<Segment>& segment);
|
||||
|
@ -108,52 +108,52 @@ public:
|
|||
|
||||
const std::string& getHost() const
|
||||
{
|
||||
return request->getHost();
|
||||
return _request->getHost();
|
||||
}
|
||||
|
||||
uint16_t getPort() const
|
||||
{
|
||||
return request->getPort();
|
||||
return _request->getPort();
|
||||
}
|
||||
|
||||
const std::string& getMethod() const
|
||||
{
|
||||
return request->getMethod();
|
||||
return _request->getMethod();
|
||||
}
|
||||
|
||||
const std::string& getProtocol() const
|
||||
{
|
||||
return request->getProtocol();
|
||||
return _request->getProtocol();
|
||||
}
|
||||
|
||||
const std::string& getCurrentURI() const
|
||||
{
|
||||
return request->getCurrentUri();
|
||||
return _request->getCurrentUri();
|
||||
}
|
||||
|
||||
const std::string& getDir() const
|
||||
{
|
||||
return request->getDir();
|
||||
return _request->getDir();
|
||||
}
|
||||
|
||||
const std::string& getFile() const
|
||||
{
|
||||
return request->getFile();
|
||||
return _request->getFile();
|
||||
}
|
||||
|
||||
const std::string& getQuery() const
|
||||
{
|
||||
return request->getQuery();
|
||||
return _request->getQuery();
|
||||
}
|
||||
|
||||
const std::string& getPreviousURI() const
|
||||
{
|
||||
return request->getPreviousUri();
|
||||
return _request->getPreviousUri();
|
||||
}
|
||||
|
||||
std::string getURIHost() const
|
||||
{
|
||||
return request->getURIHost();
|
||||
return _request->getURIHost();
|
||||
}
|
||||
|
||||
SharedHandle<Range> getRange() const;
|
||||
|
@ -166,7 +166,7 @@ public:
|
|||
|
||||
const SharedHandle<Request>& getRequest() const
|
||||
{
|
||||
return request;
|
||||
return _request;
|
||||
}
|
||||
|
||||
off_t getStartByte() const;
|
||||
|
@ -194,7 +194,7 @@ public:
|
|||
|
||||
void setUserAgent(const std::string& userAgent)
|
||||
{
|
||||
this->userAgent = userAgent;
|
||||
_userAgent = userAgent;
|
||||
}
|
||||
|
||||
// accepts multiline headers, delimited by LF
|
||||
|
|
Loading…
Reference in New Issue