2010-06-12 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

Renamed member variables.
	* src/HttpRequest.cc
	* src/HttpRequest.h
pull/1/head
Tatsuhiro Tsujikawa 2010-06-12 09:52:24 +00:00
parent c7c0ec87bf
commit f9c77a25ec
3 changed files with 43 additions and 36 deletions

View File

@ -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> 2010-06-12 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Renamed member variables. Renamed member variables.

View File

@ -56,37 +56,38 @@ namespace aria2 {
const std::string HttpRequest::USER_AGENT("aria2"); const std::string HttpRequest::USER_AGENT("aria2");
HttpRequest::HttpRequest():_contentEncodingEnabled(true), HttpRequest::HttpRequest():_contentEncodingEnabled(true),
userAgent(USER_AGENT), _userAgent(USER_AGENT),
_noCache(true), _noCache(true),
_acceptGzip(false) _acceptGzip(false)
{} {}
void HttpRequest::setSegment(const SharedHandle<Segment>& segment) void HttpRequest::setSegment(const SharedHandle<Segment>& segment)
{ {
this->segment = segment; _segment = segment;
} }
void HttpRequest::setRequest(const SharedHandle<Request>& request) void HttpRequest::setRequest(const SharedHandle<Request>& request)
{ {
this->request = request; _request = request;
} }
off_t HttpRequest::getStartByte() const off_t HttpRequest::getStartByte() const
{ {
if(segment.isNull()) { if(_segment.isNull()) {
return 0; return 0;
} else { } else {
return _fileEntry->gtoloff(segment->getPositionToWrite()); return _fileEntry->gtoloff(_segment->getPositionToWrite());
} }
} }
off_t HttpRequest::getEndByte() const off_t HttpRequest::getEndByte() const
{ {
if(segment.isNull() || request.isNull()) { if(_segment.isNull() || _request.isNull()) {
return 0; return 0;
} else { } else {
if(request->isPipeliningEnabled()) { if(_request->isPipeliningEnabled()) {
off_t endByte = _fileEntry->gtoloff(segment->getPosition()+segment->getLength()-1); off_t endByte =
_fileEntry->gtoloff(_segment->getPosition()+_segment->getLength()-1);
return std::min(endByte, static_cast<off_t>(_fileEntry->getLength()-1)); return std::min(endByte, static_cast<off_t>(_fileEntry->getLength()-1));
} else { } else {
return 0; return 0;
@ -97,7 +98,7 @@ off_t HttpRequest::getEndByte() const
RangeHandle HttpRequest::getRange() const RangeHandle HttpRequest::getRange() const
{ {
// content-length is always 0 // content-length is always 0
if(segment.isNull()) { if(_segment.isNull()) {
return SharedHandle<Range>(new Range()); return SharedHandle<Range>(new Range());
} else { } else {
return SharedHandle<Range>(new Range(getStartByte(), getEndByte(), return SharedHandle<Range>(new Range(getStartByte(), getEndByte(),
@ -107,7 +108,7 @@ RangeHandle HttpRequest::getRange() const
bool HttpRequest::isRangeSatisfied(const RangeHandle& range) const bool HttpRequest::isRangeSatisfied(const RangeHandle& range) const
{ {
if(segment.isNull()) { if(_segment.isNull()) {
return true; return true;
} }
if((getStartByte() == range->getStartByte()) && if((getStartByte() == range->getStartByte()) &&
@ -132,12 +133,12 @@ static std::string getHostText(const std::string& host, uint16_t port)
std::string HttpRequest::createRequest() std::string HttpRequest::createRequest()
{ {
_authConfig = _authConfigFactory->createAuthConfig(request, _option); _authConfig = _authConfigFactory->createAuthConfig(_request, _option);
std::string requestLine = request->getMethod(); std::string requestLine = _request->getMethod();
requestLine += " "; requestLine += " ";
if(!_proxyRequest.isNull()) { if(!_proxyRequest.isNull()) {
if(getProtocol() == Request::PROTO_FTP && if(getProtocol() == Request::PROTO_FTP &&
request->getUsername().empty() && !_authConfig.isNull()) { _request->getUsername().empty() && !_authConfig.isNull()) {
// Insert user into URI, like ftp://USER@host/ // Insert user into URI, like ftp://USER@host/
std::string uri = getCurrentURI(); std::string uri = getCurrentURI();
assert(uri.size() >= 6); assert(uri.size() >= 6);
@ -160,7 +161,7 @@ std::string HttpRequest::createRequest()
std::vector<std::pair<std::string, std::string> > builtinHds; std::vector<std::pair<std::string, std::string> > builtinHds;
builtinHds.reserve(20); builtinHds.reserve(20);
builtinHds.push_back(std::make_pair("User-Agent:", userAgent)); builtinHds.push_back(std::make_pair("User-Agent:", _userAgent));
std::string acceptTypes = "*/*"; std::string acceptTypes = "*/*";
for(std::vector<std::string>::const_iterator i = _acceptTypes.begin(), for(std::vector<std::string>::const_iterator i = _acceptTypes.begin(),
eoi = _acceptTypes.end(); i != eoi; ++i) { 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("Pragma:", "no-cache"));
builtinHds.push_back(std::make_pair("Cache-Control:", "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")); builtinHds.push_back(std::make_pair("Connection:", "close"));
} }
if(!segment.isNull() && segment->getLength() > 0 && if(!_segment.isNull() && _segment->getLength() > 0 &&
(request->isPipeliningEnabled() || getStartByte() > 0)) { (_request->isPipeliningEnabled() || getStartByte() > 0)) {
std::string rangeHeader = "bytes="; std::string rangeHeader = "bytes=";
rangeHeader += util::itos(getStartByte()); rangeHeader += util::itos(getStartByte());
rangeHeader += "-"; rangeHeader += "-";
if(request->isPipeliningEnabled()) { if(_request->isPipeliningEnabled()) {
rangeHeader += util::itos(getEndByte()); rangeHeader += util::itos(getEndByte());
} }
builtinHds.push_back(std::make_pair("Range:", rangeHeader)); builtinHds.push_back(std::make_pair("Range:", rangeHeader));
} }
if(!_proxyRequest.isNull()) { if(!_proxyRequest.isNull()) {
if(request->isKeepAliveEnabled() || request->isPipeliningEnabled()) { if(_request->isKeepAliveEnabled() || _request->isPipeliningEnabled()) {
builtinHds.push_back(std::make_pair("Proxy-Connection:", "Keep-Alive")); builtinHds.push_back(std::make_pair("Proxy-Connection:", "Keep-Alive"));
} else { } else {
builtinHds.push_back(std::make_pair("Proxy-Connection:", "close")); builtinHds.push_back(std::make_pair("Proxy-Connection:", "close"));
@ -263,7 +264,7 @@ std::string HttpRequest::createProxyRequest() const
std::string requestLine = "CONNECT "; std::string requestLine = "CONNECT ";
strappend(requestLine, hostport, " HTTP/1.1\r\n"); 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"); strappend(requestLine, "Host: ", hostport, "\r\n");
// TODO Is "Proxy-Connection" needed here? // TODO Is "Proxy-Connection" needed here?
// if(request->isKeepAliveEnabled() || request->isPipeliningEnabled()) { // if(request->isKeepAliveEnabled() || request->isPipeliningEnabled()) {

View File

@ -59,15 +59,15 @@ private:
static const std::string USER_AGENT; static const std::string USER_AGENT;
SharedHandle<Request> request; SharedHandle<Request> _request;
SharedHandle<FileEntry> _fileEntry; SharedHandle<FileEntry> _fileEntry;
SharedHandle<Segment> segment; SharedHandle<Segment> _segment;
bool _contentEncodingEnabled; bool _contentEncodingEnabled;
std::string userAgent; std::string _userAgent;
std::vector<std::string> _headers; std::vector<std::string> _headers;
@ -93,7 +93,7 @@ public:
const SharedHandle<Segment>& getSegment() const const SharedHandle<Segment>& getSegment() const
{ {
return segment; return _segment;
} }
void setSegment(const SharedHandle<Segment>& segment); void setSegment(const SharedHandle<Segment>& segment);
@ -108,52 +108,52 @@ public:
const std::string& getHost() const const std::string& getHost() const
{ {
return request->getHost(); return _request->getHost();
} }
uint16_t getPort() const uint16_t getPort() const
{ {
return request->getPort(); return _request->getPort();
} }
const std::string& getMethod() const const std::string& getMethod() const
{ {
return request->getMethod(); return _request->getMethod();
} }
const std::string& getProtocol() const const std::string& getProtocol() const
{ {
return request->getProtocol(); return _request->getProtocol();
} }
const std::string& getCurrentURI() const const std::string& getCurrentURI() const
{ {
return request->getCurrentUri(); return _request->getCurrentUri();
} }
const std::string& getDir() const const std::string& getDir() const
{ {
return request->getDir(); return _request->getDir();
} }
const std::string& getFile() const const std::string& getFile() const
{ {
return request->getFile(); return _request->getFile();
} }
const std::string& getQuery() const const std::string& getQuery() const
{ {
return request->getQuery(); return _request->getQuery();
} }
const std::string& getPreviousURI() const const std::string& getPreviousURI() const
{ {
return request->getPreviousUri(); return _request->getPreviousUri();
} }
std::string getURIHost() const std::string getURIHost() const
{ {
return request->getURIHost(); return _request->getURIHost();
} }
SharedHandle<Range> getRange() const; SharedHandle<Range> getRange() const;
@ -166,7 +166,7 @@ public:
const SharedHandle<Request>& getRequest() const const SharedHandle<Request>& getRequest() const
{ {
return request; return _request;
} }
off_t getStartByte() const; off_t getStartByte() const;
@ -194,7 +194,7 @@ public:
void setUserAgent(const std::string& userAgent) void setUserAgent(const std::string& userAgent)
{ {
this->userAgent = userAgent; _userAgent = userAgent;
} }
// accepts multiline headers, delimited by LF // accepts multiline headers, delimited by LF