Revert "Fix broken channel icon in chrome://help on CrOS" and try again
[chromium-blink-merge.git] / net / http / proxy_client_socket.h
blob2d6688f72fd84620ef57784504e264d6c52ab3f5
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef NET_HTTP_PROXY_CLIENT_SOCKET_H_
6 #define NET_HTTP_PROXY_CLIENT_SOCKET_H_
8 #include <string>
10 #include "net/socket/ssl_client_socket.h"
11 #include "net/socket/stream_socket.h"
13 class GURL;
15 namespace net {
17 class HostPortPair;
18 class HttpAuthController;
19 class HttpStream;
20 class HttpResponseInfo;
21 class HttpRequestHeaders;
22 struct HttpRequestInfo;
23 class HttpAuthController;
25 class NET_EXPORT_PRIVATE ProxyClientSocket : public StreamSocket {
26 public:
27 ProxyClientSocket() {}
28 ~ProxyClientSocket() override {}
30 // Returns the HttpResponseInfo (including HTTP Headers) from
31 // the response to the CONNECT request.
32 virtual const HttpResponseInfo* GetConnectResponseInfo() const = 0;
34 // Transfers ownership of a newly created HttpStream to the caller
35 // which can be used to read the response body.
36 virtual HttpStream* CreateConnectResponseStream() = 0;
38 // Returns the HttpAuthController which can be used
39 // to interact with an HTTP Proxy Authorization Required (407) request.
40 virtual const scoped_refptr<HttpAuthController>& GetAuthController() const
41 = 0;
43 // If Connect (or its callback) returns PROXY_AUTH_REQUESTED, then
44 // credentials should be added to the HttpAuthController before calling
45 // RestartWithAuth. Not all ProxyClientSocket implementations will be
46 // restartable. Such implementations should disconnect themselves and
47 // return OK.
48 virtual int RestartWithAuth(const CompletionCallback& callback) = 0;
50 // Returns true of the connection to the proxy is using SPDY.
51 virtual bool IsUsingSpdy() const = 0;
53 // Returns the protocol negotiated with the proxy.
54 virtual NextProto GetProtocolNegotiated() const = 0;
56 protected:
57 // The HTTP CONNECT method for establishing a tunnel connection is documented
58 // in draft-luotonen-web-proxy-tunneling-01.txt and RFC 2817, Sections 5.2
59 // and 5.3.
60 static void BuildTunnelRequest(const HostPortPair& endpoint,
61 const HttpRequestHeaders& auth_headers,
62 const std::string& user_agent,
63 std::string* request_line,
64 HttpRequestHeaders* request_headers);
66 // When an auth challenge (407 response) is received during tunnel
67 // construction/ this method should be called.
68 static int HandleProxyAuthChallenge(HttpAuthController* auth,
69 HttpResponseInfo* response,
70 const BoundNetLog& net_log);
72 // Logs (to the log and in a histogram) a blocked CONNECT response.
73 static void LogBlockedTunnelResponse(int http_response_code,
74 bool is_https_proxy);
76 // When a proxy authentication response is received during tunnel
77 // construction, this method should be called to strip everything
78 // but the auth header from the redirect response. If it returns
79 // false, the response should be discarded and tunnel construction should
80 // fail.
81 static bool SanitizeProxyAuth(HttpResponseInfo* response);
83 // When a redirect (e.g. 302 response) is received during tunnel
84 // construction, this method should be called to strip everything
85 // but the Location header from the redirect response. If it returns
86 // false, the response should be discarded and tunnel construction should
87 // fail.
88 static bool SanitizeProxyRedirect(HttpResponseInfo* response);
90 private:
91 DISALLOW_COPY_AND_ASSIGN(ProxyClientSocket);
94 } // namespace net
96 #endif // NET_HTTP_PROXY_CLIENT_SOCKET_H_