/* */ #ifndef D_HTTP_CONNECTION_H #define D_HTTP_CONNECTION_H #include "common.h" #include #include #include "SharedHandle.h" #include "SocketBuffer.h" #include "Command.h" namespace aria2 { class HttpRequest; class HttpResponse; class HttpHeaderProcessor; class Option; class Segment; class SocketCore; class SocketRecvBuffer; class HttpRequestEntry { private: SharedHandle httpRequest_; SharedHandle proc_; public: HttpRequestEntry(const SharedHandle& httpRequest); ~HttpRequestEntry(); const SharedHandle& getHttpRequest() const { return httpRequest_; } const SharedHandle& getHttpHeaderProcessor() const { return proc_; } }; typedef std::deque > HttpRequestEntries; class HttpConnection { private: cuid_t cuid_; SharedHandle socket_; SharedHandle socketRecvBuffer_; SocketBuffer socketBuffer_; const Option* option_; HttpRequestEntries outstandingHttpRequests_; std::string eraseConfidentialInfo(const std::string& request); public: HttpConnection (cuid_t cuid, const SharedHandle& socket, const SharedHandle& socketRecvBuffer); ~HttpConnection(); /** * Sends Http request. * If segment.sp+segment.ds > 0 then Range header is added. * This method is used in HTTP/HTTP downloading and FTP downloading via * HTTP proxy(GET method). * @param segment indicates starting postion of the file for downloading */ void sendRequest(const SharedHandle& httpRequest); /** * Sends Http proxy request using CONNECT method. */ void sendProxyRequest(const SharedHandle& httpRequest); /** * Receives HTTP response from the server and returns HttpResponseHandle * object which contains response header and HttpRequestHandle object * for this response. * If a response is not fully received, received header is buffured * in this object and returns 0. * You should continue to call this method until whole response header is * received and this method returns non-null HttpResponseHandle object. * * @return HttpResponse or 0 if whole response header is not received */ SharedHandle receiveResponse(); SharedHandle getFirstHttpRequest() const; bool isIssued(const SharedHandle& segment) const; bool sendBufferIsEmpty() const; void sendPendingData(); const SharedHandle& getSocketRecvBuffer() const { return socketRecvBuffer_; } }; } // namespace aria2 #endif // D_HTTP_CONNECTION_H