~alinuxninja/nginx-edge/trunk

« back to all changes in this revision

Viewing changes to debian/modules/ngx_pagespeed/psol/include/net/instaweb/http/public/external_url_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
 
/*
2
 
 * Copyright 2010 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
 
 
17
 
// Authors: jmarantz@google.com (Joshua Marantz)
18
 
//          vchudnov@google.com (Victor Chudnovsky)
19
 
 
20
 
#ifndef NET_INSTAWEB_HTTP_PUBLIC_EXTERNAL_URL_FETCHER_H_
21
 
#define NET_INSTAWEB_HTTP_PUBLIC_EXTERNAL_URL_FETCHER_H_
22
 
 
23
 
#include "net/instaweb/util/public/basictypes.h"
24
 
#include "net/instaweb/util/public/string.h"
25
 
#include "net/instaweb/util/public/string_util.h"
26
 
#include "net/instaweb/http/public/url_async_fetcher.h"
27
 
 
28
 
namespace net_instaweb {
29
 
 
30
 
class AsyncFetch;
31
 
class MessageHandler;
32
 
class RequestHeaders;
33
 
 
34
 
// Runs an external command ('wget' by default, or 'curl') via popen
35
 
// for blocking URL fetches.
36
 
 
37
 
// TODO(vchudnov): Incorporate NetcatUrlFetcher functionality into
38
 
// this class.
39
 
class ExternalUrlFetcher : public UrlAsyncFetcher {
40
 
 public:
41
 
  ExternalUrlFetcher() {}
42
 
  virtual ~ExternalUrlFetcher() {}
43
 
 
44
 
  // TODO(sligocki): Allow protocol version number (e.g. HTTP/1.1)
45
 
  // and request type (e.g. GET, POST, etc.) to be specified.
46
 
  virtual void Fetch(const GoogleString& url,
47
 
                     MessageHandler* message_handler,
48
 
                     AsyncFetch* fetch);
49
 
 
50
 
  // Default user agent to use.
51
 
  static const char kDefaultUserAgent[];
52
 
 
53
 
  // Sets the path to "binary" when fetching using "how".
54
 
  void set_binary(const GoogleString& binary);
55
 
 
56
 
 
57
 
 protected:
58
 
  // Appends to escaped_headers one header line for each Name, Value
59
 
  // pair in request_headers.
60
 
  virtual void AppendHeaders(const RequestHeaders& request_headers,
61
 
                             StringVector* escaped_headers);
62
 
 
63
 
  GoogleString binary_;
64
 
 
65
 
 private:
66
 
  virtual const char* GetFetchLabel() = 0;
67
 
 
68
 
  // Returns the external command to run in order to fetch a URL. The
69
 
  // URL and the vector of header lines must be already escaped in
70
 
  // escaped_url and escaped_headers, respectively. In addition to the
71
 
  // specified headers, the User-Agent is also explicitly set to the
72
 
  // value of user_agent, unless the latter is NULL.
73
 
  virtual GoogleString ConstructFetchCommand(
74
 
      const GoogleString& escaped_url,
75
 
      const char* user_agent,
76
 
      const StringVector& escaped_headers) = 0;
77
 
 
78
 
  DISALLOW_COPY_AND_ASSIGN(ExternalUrlFetcher);
79
 
};
80
 
 
81
 
}  // namespace net_instaweb
82
 
 
83
 
#endif  // NET_INSTAWEB_HTTP_PUBLIC_EXTERNAL_URL_FETCHER_H_