| OLD | NEW |
| 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 #include "content/test/net/url_request_mock_http_job.h" | 5 #include "content/test/net/url_request_mock_http_job.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/threading/thread_restrictions.h" | 10 #include "base/threading/thread_restrictions.h" |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 ReplaceSubstringsAfterOffset(&raw_headers, 0, "\n", std::string("\0", 1)); | 113 ReplaceSubstringsAfterOffset(&raw_headers, 0, "\n", std::string("\0", 1)); |
| 114 info->headers = new net::HttpResponseHeaders(raw_headers); | 114 info->headers = new net::HttpResponseHeaders(raw_headers); |
| 115 } | 115 } |
| 116 | 116 |
| 117 bool URLRequestMockHTTPJob::GetMimeType(std::string* mime_type) const { | 117 bool URLRequestMockHTTPJob::GetMimeType(std::string* mime_type) const { |
| 118 net::HttpResponseInfo info; | 118 net::HttpResponseInfo info; |
| 119 GetResponseInfoConst(&info); | 119 GetResponseInfoConst(&info); |
| 120 return info.headers && info.headers->GetMimeType(mime_type); | 120 return info.headers && info.headers->GetMimeType(mime_type); |
| 121 } | 121 } |
| 122 | 122 |
| 123 int URLRequestMockHTTPJob::GetResponseCode() const { |
| 124 net::HttpResponseInfo info; |
| 125 GetResponseInfoConst(&info); |
| 126 // If we have headers, get the response code from them. |
| 127 if (info.headers) |
| 128 return info.headers->response_code(); |
| 129 return net::URLRequestJob::GetResponseCode(); |
| 130 } |
| 131 |
| 123 bool URLRequestMockHTTPJob::GetCharset(std::string* charset) { | 132 bool URLRequestMockHTTPJob::GetCharset(std::string* charset) { |
| 124 net::HttpResponseInfo info; | 133 net::HttpResponseInfo info; |
| 125 GetResponseInfo(&info); | 134 GetResponseInfo(&info); |
| 126 return info.headers && info.headers->GetCharset(charset); | 135 return info.headers && info.headers->GetCharset(charset); |
| 127 } | 136 } |
| OLD | NEW |