Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
reflecting_test_fetcher.h
Go to the documentation of this file.
1 /*
2  * Copyright 2012 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 
21 
22 #ifndef NET_INSTAWEB_HTTP_PUBLIC_REFLECTING_TEST_FETCHER_H_
23 #define NET_INSTAWEB_HTTP_PUBLIC_REFLECTING_TEST_FETCHER_H_
24 
32 
33 namespace net_instaweb {
34 
35 class MessageHandler;
36 
41  public:
43  virtual ~ReflectingTestFetcher() {}
44 
45  virtual void Fetch(const GoogleString& url,
46  MessageHandler* message_handler,
47  AsyncFetch* fetch) {
48  RequestHeaders* in = fetch->request_headers();
49  ResponseHeaders* out = fetch->response_headers();
50  out->SetStatusAndReason(HttpStatus::kOK);
51  for (int i = 0; i < in->NumAttributes(); ++i) {
52  out->Add(in->Name(i), in->Value(i));
53  }
54  fetch->Write(url, message_handler);
55  fetch->Done(true);
56  }
57 
58  private:
59 
60 };
61 
62 }
63 
64 #endif
Read/write API for HTTP request (RequestHeaders is a misnomer).
Definition: request_headers.h:32
void Add(const StringPiece &name, const StringPiece &value)
ResponseHeaders * response_headers()
See doc for request_headers and set_request_headers.
void SetStatusAndReason(HttpStatus::Code code)
Sets the status code and reason_phrase based on an internal table.
Read/write API for HTTP response headers.
Definition: response_headers.h:37
RequestHeaders * request_headers()
void Done(bool success)
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
virtual void Fetch(const GoogleString &url, MessageHandler *message_handler, AsyncFetch *fetch)
Definition: reflecting_test_fetcher.h:45
Definition: async_fetch.h:53
Definition: message_handler.h:39
int NumAttributes() const
Raw access for random access to attribute name/value pairs.
Definition: reflecting_test_fetcher.h:40
virtual bool Write(const StringPiece &content, MessageHandler *handler)
Definition: url_async_fetcher.h:33