| 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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 return response_headers_->raw_headers(); | 278 return response_headers_->raw_headers(); |
| 279 } | 279 } |
| 280 | 280 |
| 281 const std::string& http_response_data() const { | 281 const std::string& http_response_data() const { |
| 282 DCHECK(finished_); | 282 DCHECK(finished_); |
| 283 return data_; | 283 return data_; |
| 284 } | 284 } |
| 285 | 285 |
| 286 virtual void OnReceivedRedirect(URLRequest* request, | 286 virtual void OnReceivedRedirect(URLRequest* request, |
| 287 const RedirectInfo& redirect_info, | 287 const RedirectInfo& redirect_info, |
| 288 bool* defer_redirect) OVERRIDE { | 288 bool* defer_redirect) override { |
| 289 DCHECK_EQ(request_.get(), request); | 289 DCHECK_EQ(request_.get(), request); |
| 290 DCHECK_EQ(base::MessageLoopForIO::current(), io_loop_); | 290 DCHECK_EQ(base::MessageLoopForIO::current(), io_loop_); |
| 291 | 291 |
| 292 if (!redirect_info.new_url.SchemeIs("http")) { | 292 if (!redirect_info.new_url.SchemeIs("http")) { |
| 293 // Prevent redirects to non-HTTP schemes, including HTTPS. This matches | 293 // Prevent redirects to non-HTTP schemes, including HTTPS. This matches |
| 294 // the initial check in OCSPServerSession::CreateRequest(). | 294 // the initial check in OCSPServerSession::CreateRequest(). |
| 295 CancelURLRequest(); | 295 CancelURLRequest(); |
| 296 } | 296 } |
| 297 } | 297 } |
| 298 | 298 |
| 299 virtual void OnResponseStarted(URLRequest* request) OVERRIDE { | 299 virtual void OnResponseStarted(URLRequest* request) override { |
| 300 DCHECK_EQ(request_.get(), request); | 300 DCHECK_EQ(request_.get(), request); |
| 301 DCHECK_EQ(base::MessageLoopForIO::current(), io_loop_); | 301 DCHECK_EQ(base::MessageLoopForIO::current(), io_loop_); |
| 302 | 302 |
| 303 int bytes_read = 0; | 303 int bytes_read = 0; |
| 304 if (request->status().is_success()) { | 304 if (request->status().is_success()) { |
| 305 response_code_ = request_->GetResponseCode(); | 305 response_code_ = request_->GetResponseCode(); |
| 306 response_headers_ = request_->response_headers(); | 306 response_headers_ = request_->response_headers(); |
| 307 response_headers_->GetMimeType(&response_content_type_); | 307 response_headers_->GetMimeType(&response_content_type_); |
| 308 request_->Read(buffer_.get(), kRecvBufferSize, &bytes_read); | 308 request_->Read(buffer_.get(), kRecvBufferSize, &bytes_read); |
| 309 } | 309 } |
| 310 OnReadCompleted(request_.get(), bytes_read); | 310 OnReadCompleted(request_.get(), bytes_read); |
| 311 } | 311 } |
| 312 | 312 |
| 313 virtual void OnReadCompleted(URLRequest* request, | 313 virtual void OnReadCompleted(URLRequest* request, |
| 314 int bytes_read) OVERRIDE { | 314 int bytes_read) override { |
| 315 DCHECK_EQ(request_.get(), request); | 315 DCHECK_EQ(request_.get(), request); |
| 316 DCHECK_EQ(base::MessageLoopForIO::current(), io_loop_); | 316 DCHECK_EQ(base::MessageLoopForIO::current(), io_loop_); |
| 317 | 317 |
| 318 do { | 318 do { |
| 319 if (!request_->status().is_success() || bytes_read <= 0) | 319 if (!request_->status().is_success() || bytes_read <= 0) |
| 320 break; | 320 break; |
| 321 data_.append(buffer_->data(), bytes_read); | 321 data_.append(buffer_->data(), bytes_read); |
| 322 } while (request_->Read(buffer_.get(), kRecvBufferSize, &bytes_read)); | 322 } while (request_->Read(buffer_.get(), kRecvBufferSize, &bytes_read)); |
| 323 | 323 |
| 324 if (!request_->status().is_io_pending()) { | 324 if (!request_->status().is_io_pending()) { |
| (...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 968 void SetURLRequestContextForNSSHttpIO(URLRequestContext* request_context) { | 968 void SetURLRequestContextForNSSHttpIO(URLRequestContext* request_context) { |
| 969 pthread_mutex_lock(&g_request_context_lock); | 969 pthread_mutex_lock(&g_request_context_lock); |
| 970 if (request_context) { | 970 if (request_context) { |
| 971 DCHECK(!g_request_context); | 971 DCHECK(!g_request_context); |
| 972 } | 972 } |
| 973 g_request_context = request_context; | 973 g_request_context = request_context; |
| 974 pthread_mutex_unlock(&g_request_context_lock); | 974 pthread_mutex_unlock(&g_request_context_lock); |
| 975 } | 975 } |
| 976 | 976 |
| 977 } // namespace net | 977 } // namespace net |
| OLD | NEW |