| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #import "ios/net/protocol_handler_util.h" | 5 #import "ios/net/protocol_handler_util.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/mac/scoped_nsobject.h" | 10 #include "base/mac/scoped_nsobject.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 // language support for exceptions is not present. These macros interfere | 32 // language support for exceptions is not present. These macros interfere |
| 33 // with the use of |@try| and |@catch| in Objective-C files such as this one. | 33 // with the use of |@try| and |@catch| in Objective-C files such as this one. |
| 34 // Undefine these macros here, after everything has been #included, since | 34 // Undefine these macros here, after everything has been #included, since |
| 35 // there will be no C++ uses and only Objective-C uses from this point on. | 35 // there will be no C++ uses and only Objective-C uses from this point on. |
| 36 #undef try | 36 #undef try |
| 37 #undef catch | 37 #undef catch |
| 38 | 38 |
| 39 namespace net { | 39 namespace net { |
| 40 namespace { | 40 namespace { |
| 41 | 41 |
| 42 const int kResponseCode = 200; | |
| 43 const char* kTextHtml = "text/html"; | 42 const char* kTextHtml = "text/html"; |
| 44 const char* kTextPlain = "text/plain"; | 43 const char* kTextPlain = "text/plain"; |
| 45 const char* kAscii = "US-ASCII"; | 44 const char* kAscii = "US-ASCII"; |
| 46 | 45 |
| 47 class HeadersURLRequestJob : public URLRequestJob { | 46 class HeadersURLRequestJob : public URLRequestJob { |
| 48 public: | 47 public: |
| 49 HeadersURLRequestJob(URLRequest* request) | 48 HeadersURLRequestJob(URLRequest* request) |
| 50 : URLRequestJob(request, nullptr) {} | 49 : URLRequestJob(request, nullptr) {} |
| 51 | 50 |
| 52 void Start() override { | 51 void Start() override { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 80 header_string.push_back('\0'); | 79 header_string.push_back('\0'); |
| 81 header_string += std::string("Foo: D"); | 80 header_string += std::string("Foo: D"); |
| 82 header_string.push_back('\0'); | 81 header_string.push_back('\0'); |
| 83 header_string += std::string("Foo: E"); | 82 header_string += std::string("Foo: E"); |
| 84 header_string.push_back('\0'); | 83 header_string.push_back('\0'); |
| 85 header_string += std::string("Bar: F"); | 84 header_string += std::string("Bar: F"); |
| 86 header_string.push_back('\0'); | 85 header_string.push_back('\0'); |
| 87 info->headers = new HttpResponseHeaders(header_string); | 86 info->headers = new HttpResponseHeaders(header_string); |
| 88 } | 87 } |
| 89 | 88 |
| 90 int GetResponseCode() const override { | |
| 91 return kResponseCode; | |
| 92 } | |
| 93 protected: | 89 protected: |
| 94 ~HeadersURLRequestJob() override {} | 90 ~HeadersURLRequestJob() override {} |
| 95 | 91 |
| 96 std::string GetContentTypeValue() const { | 92 std::string GetContentTypeValue() const { |
| 97 if (request()->url().DomainIs("badcontenttype")) | 93 if (request()->url().DomainIs("badcontenttype")) |
| 98 return "\xff"; | 94 return "\xff"; |
| 99 return kTextHtml; | 95 return kTextHtml; |
| 100 } | 96 } |
| 101 }; | 97 }; |
| 102 | 98 |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 // Some headers are added by default if missing. | 267 // Some headers are added by default if missing. |
| 272 const HttpRequestHeaders& headers = out_request->extra_request_headers(); | 268 const HttpRequestHeaders& headers = out_request->extra_request_headers(); |
| 273 std::string header; | 269 std::string header; |
| 274 EXPECT_TRUE(headers.GetHeader("Accept", &header)); | 270 EXPECT_TRUE(headers.GetHeader("Accept", &header)); |
| 275 EXPECT_EQ("*/*", header); | 271 EXPECT_EQ("*/*", header); |
| 276 EXPECT_TRUE(headers.GetHeader("Content-Type", &header)); | 272 EXPECT_TRUE(headers.GetHeader("Content-Type", &header)); |
| 277 EXPECT_EQ("application/x-www-form-urlencoded", header); | 273 EXPECT_EQ("application/x-www-form-urlencoded", header); |
| 278 } | 274 } |
| 279 | 275 |
| 280 } // namespace net | 276 } // namespace net |
| OLD | NEW |