/* */ #include "HttpRequestCommand.h" #include "HttpResponseCommand.h" #include "HttpConnection.h" #include "prefs.h" HttpRequestCommand::HttpRequestCommand(int cuid, const RequestHandle& req, RequestGroup* requestGroup, DownloadEngine* e, const SocketHandle& s) :AbstractCommand(cuid, req, requestGroup, e, s) { disableReadCheckSocket(); setWriteCheckSocket(socket); } HttpRequestCommand::~HttpRequestCommand() {} bool HttpRequestCommand::executeInternal() { socket->setBlockingMode(); if(req->getProtocol() == "https") { socket->initiateSecureConnection(); } if(!e->option->getAsBool(PREF_HTTP_KEEP_ALIVE)) { req->setKeepAlive(false); } HttpRequestHandle httpRequest = new HttpRequest(); httpRequest->setUserAgent(e->option->get(PREF_USER_AGENT)); httpRequest->setRequest(req); httpRequest->setSegment(segment); httpRequest->setEntityLength(_requestGroup->getSegmentMan()->totalSize); httpRequest->configure(e->option); HttpConnectionHandle httpConnection = new HttpConnection(cuid, socket, e->option); httpConnection->sendRequest(httpRequest); Command* command = new HttpResponseCommand(cuid, req, _requestGroup, httpConnection, e, socket); e->commands.push_back(command); return true; }