blob: 28eccee3073e6c84e4779a338e6e36eb035761e9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_DATA_REDUCTION_PROXY_COMMON_DATA_REDUCTION_PROXY_HEADERS_H_
#define COMPONENTS_DATA_REDUCTION_PROXY_COMMON_DATA_REDUCTION_PROXY_HEADERS_H_
#include <string>
#include "base/macros.h"
#include "base/time/time.h"
#include "net/proxy/proxy_service.h"
namespace net {
class HttpResponseHeaders;
} // namespace net
namespace data_reduction_proxy {
// Contains instructions contained in the Chrome-Proxy header.
struct DataReductionProxyInfo {
DataReductionProxyInfo() : bypass_all(false) {}
// True if Chrome should bypass all available data reduction proxies. False
// if only the currently connected data reduction proxy should be bypassed.
bool bypass_all;
// Amount of time to bypass the data reduction proxy or proxies.
base::TimeDelta bypass_duration;
};
// Returns true if the Chrome-Proxy header is present and contains a bypass
// delay. Sets |proxy_info->bypass_duration| to the specified delay if greater
// than 0, and to 0 otherwise to indicate that the default proxy delay
// (as specified in |ProxyList::UpdateRetryInfoOnFallback|) should be used.
// If all available data reduction proxies should by bypassed, |bypass_all| is
// set to true. |proxy_info| must be non-NULL.
bool ParseHeadersAndSetProxyInfo(const net::HttpResponseHeaders* headers,
DataReductionProxyInfo* proxy_info);
// Returns true if the response contains the data reduction proxy Via header
// value. Used to check the integrity of data reduction proxy responses.
bool HasDataReductionProxyViaHeader(const net::HttpResponseHeaders* headers);
// Returns the reason why the Chrome proxy should be bypassed or not, and
// populates |proxy_info| with information on how long to bypass if
// applicable.
net::ProxyService::DataReductionProxyBypassType GetDataReductionProxyBypassType(
const net::HttpResponseHeaders* headers,
DataReductionProxyInfo* proxy_info);
// Searches for the specified Chrome-Proxy action, and if present interprets
// its value as a duration in seconds.
bool ParseHeadersAndSetBypassDuration(const net::HttpResponseHeaders* headers,
const std::string& action_prefix,
base::TimeDelta* bypass_duration);
} // namespace data_reduction_proxy
#endif // COMPONENTS_DATA_REDUCTION_PROXY_COMMON_DATA_REDUCTION_PROXY_HEADERS_H_
|