Page Speed Optimization Libraries  1.2.24.1
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 #include "net/instaweb/http/public/async_fetch.h"
00023 #include "net/instaweb/http/public/meta_data.h"
00024 #include "net/instaweb/http/public/request_headers.h"
00025 #include "net/instaweb/http/public/response_headers.h"
00026 #include "net/instaweb/http/public/url_async_fetcher.h"
00027 #include "net/instaweb/util/public/basictypes.h"
00028 #include "net/instaweb/util/public/string.h"
00029 
00030 namespace net_instaweb {
00031 
00032 class MessageHandler;
00033 
00037 class ReflectingTestFetcher : public UrlAsyncFetcher {
00038  public:
00039   ReflectingTestFetcher() {}
00040   virtual ~ReflectingTestFetcher() {}
00041 
00042   virtual void Fetch(const GoogleString& url,
00043                      MessageHandler* message_handler,
00044                      AsyncFetch* fetch) {
00045     RequestHeaders* in = fetch->request_headers();
00046     ResponseHeaders* out = fetch->response_headers();
00047     out->SetStatusAndReason(HttpStatus::kOK);
00048     for (int i = 0; i < in->NumAttributes(); ++i) {
00049       out->Add(in->Name(i), in->Value(i));
00050     }
00051     fetch->Write(url, message_handler);
00052     fetch->Done(true);
00053   }
00054 
00055  private:
00056   DISALLOW_COPY_AND_ASSIGN(ReflectingTestFetcher);
00057 };
00058 
00059 }  
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines