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

Renamed member variables. Removed unused member variable.
	* src/AbstractProxyRequestCommand.cc
	* src/FtpInitiateConnectionCommand.cc
	* src/FtpNegotiationCommand.cc
	* src/HttpConnection.cc
	* src/HttpConnection.h
	* src/HttpInitiateConnectionCommand.cc
pull/1/head
Tatsuhiro Tsujikawa 2010-06-12 09:44:10 +00:00
parent 8742959320
commit f8590aa5b9
7 changed files with 51 additions and 45 deletions

View File

@ -1,3 +1,13 @@
2010-06-12 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Renamed member variables. Removed unused member variable.
* src/AbstractProxyRequestCommand.cc
* src/FtpInitiateConnectionCommand.cc
* src/FtpNegotiationCommand.cc
* src/HttpConnection.cc
* src/HttpConnection.h
* src/HttpInitiateConnectionCommand.cc
2010-06-12 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Removed HandleRegistry

View File

@ -64,7 +64,7 @@ AbstractProxyRequestCommand::AbstractProxyRequestCommand
:
AbstractCommand(cuid, req, fileEntry, requestGroup, e, s),
_proxyRequest(proxyRequest),
_httpConnection(new HttpConnection(cuid, s, getOption().get()))
_httpConnection(new HttpConnection(cuid, s))
{
setTimeout(getOption()->getAsInt(PREF_CONNECT_TIMEOUT));
disableReadCheckSocket();

View File

@ -104,7 +104,7 @@ Command* FtpInitiateConnectionCommand::createNextCommand
// Use GET for FTP via HTTP proxy.
getRequest()->setMethod(Request::METHOD_GET);
SharedHandle<HttpConnection> hc
(new HttpConnection(getCuid(), getSocket(), getOption().get()));
(new HttpConnection(getCuid(), getSocket()));
HttpRequestCommand* c =
new HttpRequestCommand(getCuid(), getRequest(), getFileEntry(),
@ -136,7 +136,7 @@ Command* FtpInitiateConnectionCommand::createNextCommand
// Use GET for FTP via HTTP proxy.
getRequest()->setMethod(Request::METHOD_GET);
SharedHandle<HttpConnection> hc
(new HttpConnection(getCuid(), pooledSocket, getOption().get()));
(new HttpConnection(getCuid(), pooledSocket));
HttpRequestCommand* c =
new HttpRequestCommand(getCuid(), getRequest(), getFileEntry(),

View File

@ -598,7 +598,7 @@ bool FtpNegotiationCommand::resolveProxy()
_dataSocket->establishConnection(_proxyAddr, proxyReq->getPort());
disableReadCheckSocket();
setWriteCheckSocket(_dataSocket);
_http.reset(new HttpConnection(getCuid(), _dataSocket, getOption().get()));
_http.reset(new HttpConnection(getCuid(), _dataSocket));
_sequence = SEQ_SEND_TUNNEL_REQUEST;
return false;
}

View File

@ -65,12 +65,10 @@ HttpRequestEntry::HttpRequestEntry
HttpRequestEntry::~HttpRequestEntry() {}
HttpConnection::HttpConnection(cuid_t cuid,
const SocketHandle& socket,
const Option* op):
cuid(cuid), socket(socket),
HttpConnection::HttpConnection(cuid_t cuid, const SocketHandle& socket):
_cuid(cuid), _socket(socket),
_socketBuffer(socket),
option(op), logger(LogFactory::getInstance())
_logger(LogFactory::getInstance())
{}
std::string HttpConnection::eraseConfidentialInfo(const std::string& request)
@ -95,45 +93,45 @@ std::string HttpConnection::eraseConfidentialInfo(const std::string& request)
void HttpConnection::sendRequest(const SharedHandle<HttpRequest>& httpRequest)
{
std::string request = httpRequest->createRequest();
if(logger->info()) {
logger->info(MSG_SENDING_REQUEST,
util::itos(cuid).c_str(),
eraseConfidentialInfo(request).c_str());
if(_logger->info()) {
_logger->info(MSG_SENDING_REQUEST,
util::itos(_cuid).c_str(),
eraseConfidentialInfo(request).c_str());
}
_socketBuffer.pushStr(request);
_socketBuffer.send();
SharedHandle<HttpRequestEntry> entry(new HttpRequestEntry(httpRequest));
outstandingHttpRequests.push_back(entry);
_outstandingHttpRequests.push_back(entry);
}
void HttpConnection::sendProxyRequest
(const SharedHandle<HttpRequest>& httpRequest)
{
std::string request = httpRequest->createProxyRequest();
if(logger->info()) {
logger->info(MSG_SENDING_REQUEST,
util::itos(cuid).c_str(),
eraseConfidentialInfo(request).c_str());
if(_logger->info()) {
_logger->info(MSG_SENDING_REQUEST,
util::itos(_cuid).c_str(),
eraseConfidentialInfo(request).c_str());
}
_socketBuffer.pushStr(request);
_socketBuffer.send();
SharedHandle<HttpRequestEntry> entry(new HttpRequestEntry(httpRequest));
outstandingHttpRequests.push_back(entry);
_outstandingHttpRequests.push_back(entry);
}
SharedHandle<HttpResponse> HttpConnection::receiveResponse()
{
if(outstandingHttpRequests.empty()) {
if(_outstandingHttpRequests.empty()) {
throw DL_ABORT_EX(EX_NO_HTTP_REQUEST_ENTRY_FOUND);
}
HttpRequestEntryHandle entry = outstandingHttpRequests.front();
HttpRequestEntryHandle entry = _outstandingHttpRequests.front();
HttpHeaderProcessorHandle proc = entry->getHttpHeaderProcessor();
unsigned char buf[512];
size_t size = sizeof(buf);
socket->peekData(buf, size);
_socket->peekData(buf, size);
if(size == 0) {
if(socket->wantRead() || socket->wantWrite()) {
if(_socket->wantRead() || _socket->wantWrite()) {
return SharedHandle<HttpResponse>();
} else {
throw DL_RETRY_EX(EX_INVALID_RESPONSE);
@ -141,31 +139,31 @@ SharedHandle<HttpResponse> HttpConnection::receiveResponse()
}
proc->update(buf, size);
if(!proc->eoh()) {
socket->readData(buf, size);
_socket->readData(buf, size);
return SharedHandle<HttpResponse>();
}
size_t putbackDataLength = proc->getPutBackDataLength();
size -= putbackDataLength;
socket->readData(buf, size);
if(logger->info()) {
logger->info(MSG_RECEIVE_RESPONSE,
util::itos(cuid).c_str(), proc->getHeaderString().c_str());
_socket->readData(buf, size);
if(_logger->info()) {
_logger->info(MSG_RECEIVE_RESPONSE,
util::itos(_cuid).c_str(), proc->getHeaderString().c_str());
}
SharedHandle<HttpHeader> httpHeader = proc->getHttpResponseHeader();
SharedHandle<HttpResponse> httpResponse(new HttpResponse());
httpResponse->setCuid(cuid);
httpResponse->setCuid(_cuid);
httpResponse->setHttpHeader(httpHeader);
httpResponse->setHttpRequest(entry->getHttpRequest());
outstandingHttpRequests.pop_front();
_outstandingHttpRequests.pop_front();
return httpResponse;
}
bool HttpConnection::isIssued(const SharedHandle<Segment>& segment) const
{
for(HttpRequestEntries::const_iterator itr = outstandingHttpRequests.begin(),
eoi = outstandingHttpRequests.end(); itr != eoi; ++itr) {
for(HttpRequestEntries::const_iterator itr = _outstandingHttpRequests.begin(),
eoi = _outstandingHttpRequests.end(); itr != eoi; ++itr) {
SharedHandle<HttpRequest> httpRequest = (*itr)->getHttpRequest();
if(httpRequest->getSegment() == segment) {
return true;
@ -176,10 +174,10 @@ bool HttpConnection::isIssued(const SharedHandle<Segment>& segment) const
SharedHandle<HttpRequest> HttpConnection::getFirstHttpRequest() const
{
if(outstandingHttpRequests.empty()) {
if(_outstandingHttpRequests.empty()) {
return SharedHandle<HttpRequest>();
} else {
return outstandingHttpRequests.front()->getHttpRequest();
return _outstandingHttpRequests.front()->getHttpRequest();
}
}

View File

@ -79,19 +79,17 @@ typedef std::deque<HttpRequestEntryHandle> HttpRequestEntries;
class HttpConnection {
private:
cuid_t cuid;
SharedHandle<SocketCore> socket;
cuid_t _cuid;
SharedHandle<SocketCore> _socket;
SocketBuffer _socketBuffer;
const Option* option;
Logger* logger;
const Option* _option;
Logger* _logger;
HttpRequestEntries outstandingHttpRequests;
HttpRequestEntries _outstandingHttpRequests;
std::string eraseConfidentialInfo(const std::string& request);
public:
HttpConnection(cuid_t cuid,
const SharedHandle<SocketCore>& socket,
const Option* op);
HttpConnection(cuid_t cuid, const SharedHandle<SocketCore>& socket);
/**
* Sends Http request.

View File

@ -98,7 +98,7 @@ Command* HttpInitiateConnectionCommand::createNextCommand
command = c;
} else if(proxyMethod == V_GET) {
SharedHandle<HttpConnection> httpConnection
(new HttpConnection(getCuid(), getSocket(), getOption().get()));
(new HttpConnection(getCuid(), getSocket()));
HttpRequestCommand* c = new HttpRequestCommand(getCuid(),
getRequest(),
getFileEntry(),
@ -115,7 +115,7 @@ Command* HttpInitiateConnectionCommand::createNextCommand
}
} else {
SharedHandle<HttpConnection> httpConnection
(new HttpConnection(getCuid(), pooledSocket, getOption().get()));
(new HttpConnection(getCuid(), pooledSocket));
HttpRequestCommand* c = new HttpRequestCommand(getCuid(),
getRequest(),
getFileEntry(),
@ -143,7 +143,7 @@ Command* HttpInitiateConnectionCommand::createNextCommand
setSocket(pooledSocket);
}
SharedHandle<HttpConnection> httpConnection
(new HttpConnection(getCuid(), getSocket(), getOption().get()));
(new HttpConnection(getCuid(), getSocket()));
HttpRequestCommand* c =
new HttpRequestCommand(getCuid(), getRequest(), getFileEntry(),
getRequestGroup(),