00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00018
00019 #ifndef NET_INSTAWEB_HTTP_PUBLIC_HTTP_DUMP_URL_FETCHER_H_
00020 #define NET_INSTAWEB_HTTP_PUBLIC_HTTP_DUMP_URL_FETCHER_H_
00021
00022 #include "base/scoped_ptr.h"
00023 #include "net/instaweb/http/public/url_fetcher.h"
00024 #include "net/instaweb/util/public/basictypes.h"
00025 #include "net/instaweb/util/public/file_system.h"
00026 #include "net/instaweb/util/public/string.h"
00027 #include "net/instaweb/util/public/string_util.h"
00028
00029 namespace net_instaweb {
00030
00031 class GoogleUrl;
00032 class MessageHandler;
00033 class RequestHeaders;
00034 class ResponseHeaders;
00035 class Timer;
00036 class Writer;
00037
00041
00045 class HttpDumpUrlFetcher : public UrlFetcher {
00046 public:
00047
00053 static const char kGzipContentLengthAttribute[];
00054
00055 HttpDumpUrlFetcher(const StringPiece& root_dir, FileSystem* file_system,
00056 Timer* timer);
00057 virtual ~HttpDumpUrlFetcher();
00058
00061 static bool GetFilenameFromUrl(const StringPiece& root_dir,
00062 const GoogleUrl& url,
00063 GoogleString* filename,
00064 MessageHandler* message_handler);
00065
00067 bool GetFilename(const GoogleUrl& url,
00068 GoogleString* filename,
00069 MessageHandler* message_handler) {
00070 return GetFilenameFromUrl(root_dir_, url, filename, message_handler);
00071 }
00072
00074 virtual bool StreamingFetchUrl(const GoogleString& url,
00075 const RequestHeaders& request_headers,
00076 ResponseHeaders* response_headers,
00077 Writer* fetched_content_writer,
00078 MessageHandler* message_handler);
00079
00082 bool ParseFile(FileSystem::InputFile* file,
00083 ResponseHeaders* response_headers,
00084 Writer* response_writer,
00085 MessageHandler* handler);
00086
00088 void RespondError(ResponseHeaders* response_headers, Writer* response_writer,
00089 MessageHandler* handler);
00090
00092 void set_print_urls(bool on);
00093
00094 private:
00095 GoogleString root_dir_;
00096 FileSystem* file_system_;
00097 Timer* timer_;
00098
00100 GoogleString error_body_;
00101
00102 scoped_ptr<StringSet> urls_;
00103
00104 DISALLOW_COPY_AND_ASSIGN(HttpDumpUrlFetcher);
00105 };
00106
00107 }
00108
00109 #endif ///< NET_INSTAWEB_HTTP_PUBLIC_HTTP_DUMP_URL_FETCHER_H_