Page Speed Optimization Libraries
1.2.24.1
|
00001 /* 00002 * Copyright 2010 Google Inc. 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http:///www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 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 "net/instaweb/http/public/url_fetcher.h" 00023 #include "net/instaweb/util/public/basictypes.h" 00024 #include "net/instaweb/util/public/file_system.h" 00025 #include "net/instaweb/util/public/scoped_ptr.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_