~alinuxninja/nginx-edge/trunk

« back to all changes in this revision

Viewing changes to debian/modules/ngx_pagespeed/psol/include/net/instaweb/system/public/loopback_route_fetcher.h

  • Committer: Vivian
  • Date: 2015-12-04 18:20:11 UTC
  • Revision ID: git-v1:a36f2bc32e884f7473b3a47040e5411306144d7d
* Do not extract psol.tar.gz

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// Copyright 2012 Google Inc.
2
 
//
3
 
// Licensed under the Apache License, Version 2.0 (the "License");
4
 
// you may not use this file except in compliance with the License.
5
 
// You may obtain a copy of the License at
6
 
//
7
 
//      http://www.apache.org/licenses/LICENSE-2.0
8
 
//
9
 
// Unless required by applicable law or agreed to in writing, software
10
 
// distributed under the License is distributed on an "AS IS" BASIS,
11
 
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
 
// See the License for the specific language governing permissions and
13
 
// limitations under the License.
14
 
//
15
 
// Author: morlovich@google.com (Maksim Orlovich)
16
 
//
17
 
// This fetcher routes requests to hosts that are not explicitly mentioned in
18
 
// the DomainLawyer towards our own IP, as extracted from the incoming
19
 
// connection.
20
 
 
21
 
#ifndef NET_INSTAWEB_SYSTEM_PUBLIC_LOOPBACK_ROUTE_FETCHER_H_
22
 
#define NET_INSTAWEB_SYSTEM_PUBLIC_LOOPBACK_ROUTE_FETCHER_H_
23
 
 
24
 
#include "net/instaweb/http/public/url_async_fetcher.h"
25
 
#include "net/instaweb/util/public/basictypes.h"
26
 
#include "net/instaweb/util/public/string.h"
27
 
 
28
 
struct apr_sockaddr_t;
29
 
 
30
 
namespace net_instaweb {
31
 
 
32
 
class AsyncFetch;
33
 
class RewriteOptions;
34
 
class MessageHandler;
35
 
 
36
 
// See file comment.
37
 
class LoopbackRouteFetcher : public UrlAsyncFetcher {
38
 
 public:
39
 
  // Does not take ownership of anything. own_port is the port the incoming
40
 
  // request came in on, and own_ip is the same for the IP. If the
41
 
  // backend_fetcher does actual fetching (and is not merely simulating it for
42
 
  // testing purposes) it should be the Serf fetcher, as others may not direct
43
 
  // requests this class produces properly.
44
 
  // (As this fetcher may produce requests that need to connect to some IP
45
 
  //  but have a Host: and URL from somewhere else).
46
 
  LoopbackRouteFetcher(const RewriteOptions* options,
47
 
                       const GoogleString& own_ip,
48
 
                       int own_port,
49
 
                       UrlAsyncFetcher* backend_fetcher);
50
 
  virtual ~LoopbackRouteFetcher();
51
 
 
52
 
  virtual bool SupportsHttps() const {
53
 
    return backend_fetcher_->SupportsHttps();
54
 
  }
55
 
 
56
 
  virtual void Fetch(const GoogleString& url,
57
 
                     MessageHandler* message_handler,
58
 
                     AsyncFetch* fetch);
59
 
 
60
 
  // Returns true if the given address is an IPv4 or IPv6 loopback.
61
 
  static bool IsLoopbackAddr(const apr_sockaddr_t* addr);
62
 
 
63
 
 private:
64
 
  const RewriteOptions* const options_;
65
 
  GoogleString own_ip_;
66
 
  int own_port_;
67
 
  UrlAsyncFetcher* const backend_fetcher_;
68
 
 
69
 
  DISALLOW_COPY_AND_ASSIGN(LoopbackRouteFetcher);
70
 
};
71
 
 
72
 
}  // namespace net_instaweb
73
 
 
74
 
#endif  // NET_INSTAWEB_SYSTEM_PUBLIC_LOOPBACK_ROUTE_FETCHER_H_