Page Speed Optimization Libraries  1.11.33.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends 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 
27 #include "pagespeed/kernel/base/basictypes.h"
28 #include "pagespeed/kernel/base/string.h"
29 #include "pagespeed/kernel/http/http_names.h"
30 #include "pagespeed/kernel/http/request_headers.h"
31 #include "pagespeed/kernel/http/response_headers.h"
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
ResponseHeaders * response_headers()
See doc for request_headers and set_request_headers.
RequestHeaders * request_headers()
void Done(bool success)
virtual void Fetch(const GoogleString &url, MessageHandler *message_handler, AsyncFetch *fetch)
Definition: reflecting_test_fetcher.h:45
Definition: async_fetch.h:53
Definition: reflecting_test_fetcher.h:40
virtual bool Write(const StringPiece &content, MessageHandler *handler)
Definition: url_async_fetcher.h:33