Page Speed Optimization Libraries  1.8.31.3
net/instaweb/http/public/reflecting_test_fetcher.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2012 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 
00021 
00022 #ifndef NET_INSTAWEB_HTTP_PUBLIC_REFLECTING_TEST_FETCHER_H_
00023 #define NET_INSTAWEB_HTTP_PUBLIC_REFLECTING_TEST_FETCHER_H_
00024 
00025 #include "net/instaweb/http/public/async_fetch.h"
00026 #include "net/instaweb/http/public/meta_data.h"
00027 #include "net/instaweb/http/public/request_headers.h"
00028 #include "net/instaweb/http/public/response_headers.h"
00029 #include "net/instaweb/http/public/url_async_fetcher.h"
00030 #include "net/instaweb/util/public/basictypes.h"
00031 #include "net/instaweb/util/public/string.h"
00032 
00033 namespace net_instaweb {
00034 
00035 class MessageHandler;
00036 
00040 class ReflectingTestFetcher : public UrlAsyncFetcher {
00041  public:
00042   ReflectingTestFetcher() {}
00043   virtual ~ReflectingTestFetcher() {}
00044 
00045   virtual void Fetch(const GoogleString& url,
00046                      MessageHandler* message_handler,
00047                      AsyncFetch* fetch) {
00048     RequestHeaders* in = fetch->request_headers();
00049     ResponseHeaders* out = fetch->response_headers();
00050     out->SetStatusAndReason(HttpStatus::kOK);
00051     for (int i = 0; i < in->NumAttributes(); ++i) {
00052       out->Add(in->Name(i), in->Value(i));
00053     }
00054     fetch->Write(url, message_handler);
00055     fetch->Done(true);
00056   }
00057 
00058  private:
00059   DISALLOW_COPY_AND_ASSIGN(ReflectingTestFetcher);
00060 };
00061 
00062 }  
00063 
00064 #endif  ///< NET_INSTAWEB_HTTP_PUBLIC_REFLECTING_TEST_FETCHER_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines