OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #include "net/ocsp/nss_ocsp.h" | 5 #include "net/ocsp/nss_ocsp.h" |
6 | 6 |
7 #include <certt.h> | 7 #include <certt.h> |
8 #include <certdb.h> | 8 #include <certdb.h> |
9 #include <ocsp.h> | 9 #include <ocsp.h> |
10 #include <nspr.h> | 10 #include <nspr.h> |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 return response_headers_->raw_headers(); | 247 return response_headers_->raw_headers(); |
248 } | 248 } |
249 | 249 |
250 const std::string& http_response_data() const { | 250 const std::string& http_response_data() const { |
251 DCHECK(finished_); | 251 DCHECK(finished_); |
252 return data_; | 252 return data_; |
253 } | 253 } |
254 | 254 |
255 virtual void OnReceivedRedirect(net::URLRequest* request, | 255 virtual void OnReceivedRedirect(net::URLRequest* request, |
256 const GURL& new_url, | 256 const GURL& new_url, |
257 bool* defer_redirect) { | 257 bool* defer_redirect) OVERRIDE { |
258 DCHECK_EQ(request, request_); | 258 DCHECK_EQ(request, request_); |
259 DCHECK_EQ(MessageLoopForIO::current(), io_loop_); | 259 DCHECK_EQ(MessageLoopForIO::current(), io_loop_); |
260 | 260 |
261 if (!new_url.SchemeIs("http")) { | 261 if (!new_url.SchemeIs("http")) { |
262 // Prevent redirects to non-HTTP schemes, including HTTPS. This matches | 262 // Prevent redirects to non-HTTP schemes, including HTTPS. This matches |
263 // the initial check in OCSPServerSession::CreateRequest(). | 263 // the initial check in OCSPServerSession::CreateRequest(). |
264 CancelURLRequest(); | 264 CancelURLRequest(); |
265 } | 265 } |
266 } | 266 } |
267 | 267 |
268 virtual void OnResponseStarted(net::URLRequest* request) { | 268 virtual void OnResponseStarted(net::URLRequest* request) OVERRIDE { |
269 DCHECK_EQ(request, request_); | 269 DCHECK_EQ(request, request_); |
270 DCHECK_EQ(MessageLoopForIO::current(), io_loop_); | 270 DCHECK_EQ(MessageLoopForIO::current(), io_loop_); |
271 | 271 |
272 int bytes_read = 0; | 272 int bytes_read = 0; |
273 if (request->status().is_success()) { | 273 if (request->status().is_success()) { |
274 response_code_ = request_->GetResponseCode(); | 274 response_code_ = request_->GetResponseCode(); |
275 response_headers_ = request_->response_headers(); | 275 response_headers_ = request_->response_headers(); |
276 response_headers_->GetMimeType(&response_content_type_); | 276 response_headers_->GetMimeType(&response_content_type_); |
277 request_->Read(buffer_, kRecvBufferSize, &bytes_read); | 277 request_->Read(buffer_, kRecvBufferSize, &bytes_read); |
278 } | 278 } |
279 OnReadCompleted(request_, bytes_read); | 279 OnReadCompleted(request_, bytes_read); |
280 } | 280 } |
281 | 281 |
282 virtual void OnReadCompleted(net::URLRequest* request, int bytes_read) { | 282 virtual void OnReadCompleted(net::URLRequest* request, |
| 283 int bytes_read) OVERRIDE { |
283 DCHECK_EQ(request, request_); | 284 DCHECK_EQ(request, request_); |
284 DCHECK_EQ(MessageLoopForIO::current(), io_loop_); | 285 DCHECK_EQ(MessageLoopForIO::current(), io_loop_); |
285 | 286 |
286 do { | 287 do { |
287 if (!request_->status().is_success() || bytes_read <= 0) | 288 if (!request_->status().is_success() || bytes_read <= 0) |
288 break; | 289 break; |
289 data_.append(buffer_->data(), bytes_read); | 290 data_.append(buffer_->data(), bytes_read); |
290 } while (request_->Read(buffer_, kRecvBufferSize, &bytes_read)); | 291 } while (request_->Read(buffer_, kRecvBufferSize, &bytes_read)); |
291 | 292 |
292 if (!request_->status().is_io_pending()) { | 293 if (!request_->status().is_io_pending()) { |
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
930 void SetURLRequestContextForNSSHttpIO(URLRequestContext* request_context) { | 931 void SetURLRequestContextForNSSHttpIO(URLRequestContext* request_context) { |
931 pthread_mutex_lock(&g_request_context_lock); | 932 pthread_mutex_lock(&g_request_context_lock); |
932 if (request_context) { | 933 if (request_context) { |
933 DCHECK(!g_request_context); | 934 DCHECK(!g_request_context); |
934 } | 935 } |
935 g_request_context = request_context; | 936 g_request_context = request_context; |
936 pthread_mutex_unlock(&g_request_context_lock); | 937 pthread_mutex_unlock(&g_request_context_lock); |
937 } | 938 } |
938 | 939 |
939 } // namespace net | 940 } // namespace net |
OLD | NEW |