Page Speed Optimization Libraries
1.5.27.2
|
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/request_context.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/scoped_ptr.h" 00027 #include "net/instaweb/util/public/string.h" 00028 #include "net/instaweb/util/public/string_util.h" 00029 00030 namespace net_instaweb { 00031 00032 class GoogleUrl; 00033 class MessageHandler; 00034 class RequestHeaders; 00035 class ResponseHeaders; 00036 class Timer; 00037 class Writer; 00038 00042 00046 class HttpDumpUrlFetcher : public UrlFetcher { 00047 public: 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 const RequestContextPtr& request_context); 00080 00083 bool ParseFile(FileSystem::InputFile* file, 00084 ResponseHeaders* response_headers, 00085 Writer* response_writer, 00086 MessageHandler* handler); 00087 00089 void RespondError(ResponseHeaders* response_headers, Writer* response_writer, 00090 MessageHandler* handler); 00091 00093 void set_print_urls(bool on); 00094 00095 private: 00096 GoogleString root_dir_; 00097 FileSystem* file_system_; 00098 Timer* timer_; 00099 00101 GoogleString error_body_; 00102 00103 scoped_ptr<StringSet> urls_; 00104 00105 DISALLOW_COPY_AND_ASSIGN(HttpDumpUrlFetcher); 00106 }; 00107 00108 } 00109 00110 #endif ///< NET_INSTAWEB_HTTP_PUBLIC_HTTP_DUMP_URL_FETCHER_H_