Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: net/http/http_proxy_client_socket.h

Issue 9148011: Allow chrome to handle 407 auth challenges to CONNECT requests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NET_HTTP_HTTP_PROXY_CLIENT_SOCKET_H_ 5 #ifndef NET_HTTP_HTTP_PROXY_CLIENT_SOCKET_H_
6 #define NET_HTTP_HTTP_PROXY_CLIENT_SOCKET_H_ 6 #define NET_HTTP_HTTP_PROXY_CLIENT_SOCKET_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "net/base/completion_callback.h" 13 #include "net/base/completion_callback.h"
14 #include "net/base/host_port_pair.h" 14 #include "net/base/host_port_pair.h"
15 #include "net/base/net_log.h" 15 #include "net/base/net_log.h"
16 #include "net/http/http_auth_controller.h" 16 #include "net/http/http_auth_controller.h"
17 #include "net/http/http_request_headers.h" 17 #include "net/http/http_request_headers.h"
18 #include "net/http/http_request_info.h" 18 #include "net/http/http_request_info.h"
19 #include "net/http/http_response_info.h" 19 #include "net/http/http_response_info.h"
20 #include "net/http/proxy_client_socket.h" 20 #include "net/http/proxy_client_socket.h"
21 #include "net/socket/ssl_client_socket.h" 21 #include "net/socket/ssl_client_socket.h"
22 22
23 class GURL; 23 class GURL;
24 24
25 namespace net { 25 namespace net {
26 26
27 class AddressList; 27 class AddressList;
28 class ClientSocketHandle; 28 class ClientSocketHandle;
29 class GrowableIOBuffer; 29 class GrowableIOBuffer;
30 class HttpAuthCache;
31 class HttpStream; 30 class HttpStream;
32 class HttpStreamParser; 31 class HttpStreamParser;
33 class IOBuffer; 32 class IOBuffer;
34 33
35 class HttpProxyClientSocket : public ProxyClientSocket { 34 class HttpProxyClientSocket : public ProxyClientSocket {
36 public: 35 public:
37 // Takes ownership of |transport_socket|, which should already be connected 36 // Takes ownership of |transport_socket|, which should already be connected
38 // by the time Connect() is called. If tunnel is true then on Connect() 37 // by the time Connect() is called. If tunnel is true then on Connect()
39 // this socket will establish an Http tunnel. 38 // this socket will establish an Http tunnel.
40 HttpProxyClientSocket(ClientSocketHandle* transport_socket, 39 HttpProxyClientSocket(ClientSocketHandle* transport_socket,
41 const GURL& request_url, 40 const GURL& request_url,
42 const std::string& user_agent, 41 const std::string& user_agent,
43 const HostPortPair& endpoint, 42 const HostPortPair& endpoint,
44 const HostPortPair& proxy_server, 43 const HostPortPair& proxy_server,
45 HttpAuthCache* http_auth_cache, 44 HttpAuthController* http_auth_controller,
46 HttpAuthHandlerFactory* http_auth_handler_factory,
47 bool tunnel, 45 bool tunnel,
48 bool using_spdy, 46 bool using_spdy,
49 SSLClientSocket::NextProto protocol_negotiated, 47 SSLClientSocket::NextProto protocol_negotiated,
50 bool is_https_proxy); 48 bool is_https_proxy);
51 49
52 // On destruction Disconnect() is called. 50 // On destruction Disconnect() is called.
53 virtual ~HttpProxyClientSocket(); 51 virtual ~HttpProxyClientSocket();
54 52
55 // If Connect (or its callback) returns PROXY_AUTH_REQUESTED, then
56 // credentials should be added to the HttpAuthController before calling
57 // RestartWithAuth.
58 int RestartWithAuth(const CompletionCallback& callback);
59
60 const scoped_refptr<HttpAuthController>& auth_controller() {
61 return auth_;
62 }
63
64 bool using_spdy() { 53 bool using_spdy() {
65 return using_spdy_; 54 return using_spdy_;
66 } 55 }
67 56
68 SSLClientSocket::NextProto protocol_negotiated() { 57 SSLClientSocket::NextProto protocol_negotiated() {
69 return protocol_negotiated_; 58 return protocol_negotiated_;
70 } 59 }
71 60
72 // ProxyClientSocket implementation. 61 // ProxyClientSocket implementation.
73 virtual const HttpResponseInfo* GetConnectResponseInfo() const OVERRIDE; 62 virtual const HttpResponseInfo* GetConnectResponseInfo() const OVERRIDE;
74 virtual HttpStream* CreateConnectResponseStream() OVERRIDE; 63 virtual HttpStream* CreateConnectResponseStream() OVERRIDE;
64 virtual int RestartWithAuth(const CompletionCallback& callback) OVERRIDE;
65 virtual const scoped_refptr<HttpAuthController>& auth_controller() OVERRIDE;
75 66
76 // StreamSocket implementation. 67 // StreamSocket implementation.
77 virtual int Connect(const CompletionCallback& callback) OVERRIDE; 68 virtual int Connect(const CompletionCallback& callback) OVERRIDE;
78 virtual void Disconnect() OVERRIDE; 69 virtual void Disconnect() OVERRIDE;
79 virtual bool IsConnected() const OVERRIDE; 70 virtual bool IsConnected() const OVERRIDE;
80 virtual bool IsConnectedAndIdle() const OVERRIDE; 71 virtual bool IsConnectedAndIdle() const OVERRIDE;
81 virtual const BoundNetLog& NetLog() const OVERRIDE; 72 virtual const BoundNetLog& NetLog() const OVERRIDE;
82 virtual void SetSubresourceSpeculation() OVERRIDE; 73 virtual void SetSubresourceSpeculation() OVERRIDE;
83 virtual void SetOmniboxSpeculation() OVERRIDE; 74 virtual void SetOmniboxSpeculation() OVERRIDE;
84 virtual bool WasEverUsed() const OVERRIDE; 75 virtual bool WasEverUsed() const OVERRIDE;
(...skipping 30 matching lines...) Expand all
115 }; 106 };
116 107
117 // The size in bytes of the buffer we use to drain the response body that 108 // The size in bytes of the buffer we use to drain the response body that
118 // we want to throw away. The response body is typically a small error 109 // we want to throw away. The response body is typically a small error
119 // page just a few hundred bytes long. 110 // page just a few hundred bytes long.
120 static const int kDrainBodyBufferSize = 1024; 111 static const int kDrainBodyBufferSize = 1024;
121 112
122 int PrepareForAuthRestart(); 113 int PrepareForAuthRestart();
123 int DidDrainBodyForAuthRestart(bool keep_alive); 114 int DidDrainBodyForAuthRestart(bool keep_alive);
124 115
125 int HandleAuthChallenge();
126
127 void LogBlockedTunnelResponse(int response_code) const; 116 void LogBlockedTunnelResponse(int response_code) const;
128 117
129 void DoCallback(int result); 118 void DoCallback(int result);
130 void OnIOComplete(int result); 119 void OnIOComplete(int result);
131 120
132 int DoLoop(int last_io_result); 121 int DoLoop(int last_io_result);
133 int DoGenerateAuthToken(); 122 int DoGenerateAuthToken();
134 int DoGenerateAuthTokenComplete(int result); 123 int DoGenerateAuthTokenComplete(int result);
135 int DoSendRequest(); 124 int DoSendRequest();
136 int DoSendRequestComplete(int result); 125 int DoSendRequestComplete(int result);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 HttpRequestHeaders request_headers_; 162 HttpRequestHeaders request_headers_;
174 163
175 const BoundNetLog net_log_; 164 const BoundNetLog net_log_;
176 165
177 DISALLOW_COPY_AND_ASSIGN(HttpProxyClientSocket); 166 DISALLOW_COPY_AND_ASSIGN(HttpProxyClientSocket);
178 }; 167 };
179 168
180 } // namespace net 169 } // namespace net
181 170
182 #endif // NET_HTTP_HTTP_PROXY_CLIENT_SOCKET_H_ 171 #endif // NET_HTTP_HTTP_PROXY_CLIENT_SOCKET_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698