/* */ #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: std::shared_ptr httpConnection_; bool handleDefaultEncoding(std::unique_ptr httpResponse); bool handleOtherEncoding(std::unique_ptr httpResponse); bool skipResponseBody(std::unique_ptr httpResponse); std::unique_ptr createHttpDownloadCommand (std::unique_ptr httpResponse, std::unique_ptr 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 std::shared_ptr& dctx, const Checksum& checksum); #endif // ENABLE_MESSAGE_DIGEST protected: bool executeInternal(); bool shouldInflateContentEncoding(HttpResponse* httpResponse); public: HttpResponseCommand(cuid_t cuid, const std::shared_ptr& req, const std::shared_ptr& fileEntry, RequestGroup* requestGroup, const std::shared_ptr& httpConnection, DownloadEngine* e, const std::shared_ptr& s); ~HttpResponseCommand(); }; } // namespace aria2 #endif // D_HTTP_RESPONSE_COMMAND_H