Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
http_dump_url_fetcher.h
Go to the documentation of this file.
1 /*
2  * Copyright 2010 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http:///www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
18 
19 #ifndef NET_INSTAWEB_HTTP_PUBLIC_HTTP_DUMP_URL_FETCHER_H_
20 #define NET_INSTAWEB_HTTP_PUBLIC_HTTP_DUMP_URL_FETCHER_H_
21 
28 
29 namespace net_instaweb {
30 
31 class AsyncFetch;
32 class GoogleUrl;
33 class MessageHandler;
34 class ResponseHeaders;
35 class Timer;
36 class Writer;
37 
41 
46  public:
52  static const char kGzipContentLengthAttribute[];
53 
54  HttpDumpUrlFetcher(const StringPiece& root_dir, FileSystem* file_system,
55  Timer* timer);
56  virtual ~HttpDumpUrlFetcher();
57 
60  static bool GetFilenameFromUrl(const StringPiece& root_dir,
61  const GoogleUrl& url,
62  GoogleString* filename,
63  MessageHandler* message_handler);
64 
66  bool GetFilename(const GoogleUrl& url,
67  GoogleString* filename,
68  MessageHandler* message_handler) {
69  return GetFilenameFromUrl(root_dir_, url, filename, message_handler);
70  }
71 
73  virtual void Fetch(const GoogleString& url,
74  MessageHandler* message_handler,
75  AsyncFetch* fetch);
76 
80  ResponseHeaders* response_headers,
81  Writer* response_writer,
82  MessageHandler* handler);
83 
85  void RespondError(ResponseHeaders* response_headers, Writer* response_writer,
86  MessageHandler* handler);
87 
89  void set_print_urls(bool on);
90 
91  private:
92  GoogleString root_dir_;
93  FileSystem* file_system_;
94  Timer* timer_;
95 
97  GoogleString error_body_;
98 
100 
101 
102 };
103 
104 }
105 
106 #endif
class GoogleUrl
Definition: google_url.h:58
Definition: http_dump_url_fetcher.h:45
bool ParseFile(FileSystem::InputFile *file, ResponseHeaders *response_headers, Writer *response_writer, MessageHandler *handler)
virtual void Fetch(const GoogleString &url, MessageHandler *message_handler, AsyncFetch *fetch)
This is a synchronous/blocking implementation.
void set_print_urls(bool on)
Print URLs each time they are fetched.
Read/write API for HTTP response headers.
Definition: response_headers.h:37
bool GetFilename(const GoogleUrl &url, GoogleString *filename, MessageHandler *message_handler)
Non-static version that uses the fetcher's root dir.
Definition: http_dump_url_fetcher.h:66
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
Definition: async_fetch.h:53
Definition: file_system.h:76
Interface for writing bytes to an output stream.
Definition: writer.h:29
Definition: file_system.h:96
static const char kGzipContentLengthAttribute[]
Definition: http_dump_url_fetcher.h:52
void RespondError(ResponseHeaders *response_headers, Writer *response_writer, MessageHandler *handler)
Helper function to return a generic error response.
static bool GetFilenameFromUrl(const StringPiece &root_dir, const GoogleUrl &url, GoogleString *filename, MessageHandler *message_handler)
Definition: message_handler.h:39
Timer interface, made virtual so it can be mocked for tests.
Definition: timer.h:27
Definition: url_async_fetcher.h:33