/* */ #ifndef D_HTTP_RESPONSE_COMMAND_H #define D_HTTP_RESPONSE_COMMAND_H #include "AbstractCommand.h" #include "TimeA2.h" namespace aria2 { class HttpConnection; class HttpDownloadCommand; class HttpResponse; class SocketCore; class StreamFilter; #ifdef ENABLE_MESSAGE_DIGEST class Checksum; #endif // ENABLE_MESSAGE_DIGEST // HttpResponseCommand receives HTTP response header from remote // server. Because network I/O is non-blocking, execute() returns // false when all response headers are not received. Subsequent calls // of execute() receives remaining response headers and when all // headers are received, it examines headers. If status code is 200 // or 206 and Range header satisfies requested range, it creates // HttpDownloadCommand to receive response entity body. Otherwise, it // creates HttpSkipResponseCommand to receive response entity body and // returns true. Handling errors such as 404 or redirect is handled in // HttpSkipResponseCommand. class HttpResponseCommand : public AbstractCommand { private: SharedHandle httpConnection_; bool handleDefaultEncoding(const SharedHandle& httpResponse); bool handleOtherEncoding(const SharedHandle& httpResponse); bool skipResponseBody(const SharedHandle& httpResponse); HttpDownloadCommand* createHttpDownloadCommand (const SharedHandle& httpResponse, const SharedHandle& streamFilter); void updateLastModifiedTime(const Time& lastModified); void poolConnection(); void onDryRunFileFound(); #ifdef ENABLE_MESSAGE_DIGEST // Returns true if dctx and checksum has same hash type and hash // value. If they have same hash type but different hash value, // throws exception. Otherwise returns false. bool checkChecksum (const SharedHandle& dctx, const Checksum& checksum); #endif // ENABLE_MESSAGE_DIGEST protected: bool executeInternal(); bool shouldInflateContentEncoding (const SharedHandle& httpResponse); public: HttpResponseCommand(cuid_t cuid, const SharedHandle& req, const SharedHandle& fileEntry, RequestGroup* requestGroup, const SharedHandle& httpConnection, DownloadEngine* e, const SharedHandle& s); ~HttpResponseCommand(); }; } // namespace aria2 #endif // D_HTTP_RESPONSE_COMMAND_H