Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
apache_fetch.h
Go to the documentation of this file.
1 // Copyright 2015 Google Inc.
17 
18 #ifndef PAGESPEED_APACHE_FETCH_H_
19 #define PAGESPEED_APACHE_FETCH_H_
20 
22 #include "net/instaweb/http/public/request_context.h"
31 #include "pagespeed/kernel/base/thread_annotations.h"
35 
36 namespace net_instaweb {
37 
44 class ApacheFetch : public AsyncFetch {
45  public:
50  ApacheFetch(const GoogleString& mapped_url, StringPiece debug_info,
51  RewriteDriver* driver, ApacheWriter* apache_writer,
54  const RewriteOptions* options, MessageHandler* handler);
55  virtual ~ApacheFetch();
56 
66  void set_handle_error(bool x) { handle_error_ = x; }
67 
72  void set_buffered(bool x) { buffered_ = x; }
73 
75  void Wait() LOCKS_EXCLUDED(scheduler_->mutex());
76 
77  bool status_ok() const { return status_ok_; }
78 
79  virtual bool IsCachedResultValid(const ResponseHeaders& headers)
80  LOCKS_EXCLUDED(scheduler_->mutex());
81 
85  void set_is_proxy(bool x) { is_proxy_ = x; }
86 
87  protected:
88  virtual void HandleHeadersComplete() LOCKS_EXCLUDED(scheduler_->mutex());
89  virtual void HandleDone(bool success) LOCKS_EXCLUDED(scheduler_->mutex());
90  virtual bool HandleFlush(MessageHandler* handler)
91  LOCKS_EXCLUDED(scheduler_->mutex());
92  virtual bool HandleWrite(const StringPiece& sp, MessageHandler* handler)
93  LOCKS_EXCLUDED(scheduler_->mutex());
94 
95  private:
96  void SendOutHeaders();
97 
98  GoogleString mapped_url_;
99  scoped_ptr<ApacheWriter> apache_writer_;
100  const RewriteOptions* options_ GUARDED_BY(scheduler_->mutex());
101 
102  MessageHandler* message_handler_;
103 
104  bool done_ GUARDED_BY(scheduler_->mutex());
105  bool wait_called_;
106  bool handle_error_;
107  bool squelch_output_;
108  bool status_ok_;
109  bool is_proxy_;
110  bool buffered_;
111  GoogleString debug_info_;
112  GoogleString output_bytes_;
113  RewriteDriver* driver_;
114  Scheduler* scheduler_;
115 
116 
117 };
118 
119 }
120 
121 #endif
Definition: apache_fetch.h:44
Read/write API for HTTP request (RequestHeaders is a misnomer).
Definition: request_headers.h:32
ApacheFetch(const GoogleString &mapped_url, StringPiece debug_info, RewriteDriver *driver, ApacheWriter *apache_writer, RequestHeaders *request_headers, const RequestContextPtr &request_context, const RewriteOptions *options, MessageHandler *handler)
virtual const RequestContextPtr & request_context()
Definition: async_fetch.h:151
void set_handle_error(bool x)
Definition: apache_fetch.h:66
RequestHeaders * request_headers()
Definition: scoped_ptr.h:30
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
Definition: apache_writer.h:36
Definition: async_fetch.h:53
Definition: rewrite_driver.h:100
Definition: message_handler.h:39
void set_is_proxy(bool x)
Definition: apache_fetch.h:85
Definition: scheduler.h:47
void set_buffered(bool x)
Definition: apache_fetch.h:72
Definition: rewrite_options.h:84
void Wait() LOCKS_EXCLUDED(scheduler_-> mutex())
Blocks waiting for the fetch to complete.
virtual bool IsCachedResultValid(const ResponseHeaders &headers) LOCKS_EXCLUDED(scheduler_-> mutex())