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

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
« no previous file with comments | « net/http/http_network_transaction_unittest.cc ('k') | net/http/http_proxy_client_socket.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>& GetAuthController() 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 17 matching lines...) Expand all
102 enum State { 93 enum State {
103 STATE_NONE, 94 STATE_NONE,
104 STATE_GENERATE_AUTH_TOKEN, 95 STATE_GENERATE_AUTH_TOKEN,
105 STATE_GENERATE_AUTH_TOKEN_COMPLETE, 96 STATE_GENERATE_AUTH_TOKEN_COMPLETE,
106 STATE_SEND_REQUEST, 97 STATE_SEND_REQUEST,
107 STATE_SEND_REQUEST_COMPLETE, 98 STATE_SEND_REQUEST_COMPLETE,
108 STATE_READ_HEADERS, 99 STATE_READ_HEADERS,
109 STATE_READ_HEADERS_COMPLETE, 100 STATE_READ_HEADERS_COMPLETE,
110 STATE_DRAIN_BODY, 101 STATE_DRAIN_BODY,
111 STATE_DRAIN_BODY_COMPLETE, 102 STATE_DRAIN_BODY_COMPLETE,
112 STATE_TCP_RESTART,
113 STATE_TCP_RESTART_COMPLETE,
114 STATE_DONE, 103 STATE_DONE,
115 }; 104 };
116 105
117 // The size in bytes of the buffer we use to drain the response body that 106 // 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 107 // we want to throw away. The response body is typically a small error
119 // page just a few hundred bytes long. 108 // page just a few hundred bytes long.
120 static const int kDrainBodyBufferSize = 1024; 109 static const int kDrainBodyBufferSize = 1024;
121 110
122 int PrepareForAuthRestart(); 111 int PrepareForAuthRestart();
123 int DidDrainBodyForAuthRestart(bool keep_alive); 112 int DidDrainBodyForAuthRestart(bool keep_alive);
124 113
125 int HandleAuthChallenge();
126
127 void LogBlockedTunnelResponse(int response_code) const; 114 void LogBlockedTunnelResponse(int response_code) const;
128 115
129 void DoCallback(int result); 116 void DoCallback(int result);
130 void OnIOComplete(int result); 117 void OnIOComplete(int result);
131 118
132 int DoLoop(int last_io_result); 119 int DoLoop(int last_io_result);
133 int DoGenerateAuthToken(); 120 int DoGenerateAuthToken();
134 int DoGenerateAuthTokenComplete(int result); 121 int DoGenerateAuthTokenComplete(int result);
135 int DoSendRequest(); 122 int DoSendRequest();
136 int DoSendRequestComplete(int result); 123 int DoSendRequestComplete(int result);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 HttpRequestHeaders request_headers_; 160 HttpRequestHeaders request_headers_;
174 161
175 const BoundNetLog net_log_; 162 const BoundNetLog net_log_;
176 163
177 DISALLOW_COPY_AND_ASSIGN(HttpProxyClientSocket); 164 DISALLOW_COPY_AND_ASSIGN(HttpProxyClientSocket);
178 }; 165 };
179 166
180 } // namespace net 167 } // namespace net
181 168
182 #endif // NET_HTTP_HTTP_PROXY_CLIENT_SOCKET_H_ 169 #endif // NET_HTTP_HTTP_PROXY_CLIENT_SOCKET_H_
OLDNEW
« no previous file with comments | « net/http/http_network_transaction_unittest.cc ('k') | net/http/http_proxy_client_socket.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698