| 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/i18n/icu_encoding_detection.h" | 10 #include "base/i18n/icu_encoding_detection.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 return [[[NSURLResponse alloc] initWithURL:url | 83 return [[[NSURLResponse alloc] initWithURL:url |
| 84 MIMEType:mime_type | 84 MIMEType:mime_type |
| 85 expectedContentLength:-1 | 85 expectedContentLength:-1 |
| 86 textEncodingName:charset] autorelease]; | 86 textEncodingName:charset] autorelease]; |
| 87 } else { | 87 } else { |
| 88 // Iterate over all the headers and copy them. | 88 // Iterate over all the headers and copy them. |
| 89 bool has_content_type_header = false; | 89 bool has_content_type_header = false; |
| 90 NSMutableDictionary* header_fields = [NSMutableDictionary dictionary]; | 90 NSMutableDictionary* header_fields = [NSMutableDictionary dictionary]; |
| 91 HttpResponseHeaders* headers = request->response_headers(); | 91 HttpResponseHeaders* headers = request->response_headers(); |
| 92 if (headers != nullptr) { | 92 if (headers != nullptr) { |
| 93 void* iter = nullptr; | 93 size_t iter = 0; |
| 94 std::string name, value; | 94 std::string name, value; |
| 95 while (headers->EnumerateHeaderLines(&iter, &name, &value)) { | 95 while (headers->EnumerateHeaderLines(iter, &name, &value)) { |
| 96 NSString* key = base::SysUTF8ToNSString(name); | 96 NSString* key = base::SysUTF8ToNSString(name); |
| 97 if (!key) { | 97 if (!key) { |
| 98 DLOG(ERROR) << "Header name is not in UTF8: " << name; | 98 DLOG(ERROR) << "Header name is not in UTF8: " << name; |
| 99 // Skip the invalid header. | 99 // Skip the invalid header. |
| 100 continue; | 100 continue; |
| 101 } | 101 } |
| 102 // Do not copy "Cache-Control" headers as we provide our own controls. | 102 // Do not copy "Cache-Control" headers as we provide our own controls. |
| 103 if ([key caseInsensitiveCompare:@"cache-control"] == NSOrderedSame) | 103 if ([key caseInsensitiveCompare:@"cache-control"] == NSOrderedSame) |
| 104 continue; | 104 continue; |
| 105 if ([key caseInsensitiveCompare:kContentType] == NSOrderedSame) { | 105 if ([key caseInsensitiveCompare:kContentType] == NSOrderedSame) { |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 if (out_request->has_upload() && out_request->method() == "POST") { | 204 if (out_request->has_upload() && out_request->method() == "POST") { |
| 205 DLOG_IF(WARNING, !net_headers.HasHeader(HttpRequestHeaders::kContentType)) | 205 DLOG_IF(WARNING, !net_headers.HasHeader(HttpRequestHeaders::kContentType)) |
| 206 << "Missing \"Content-Type\" header in POST request."; | 206 << "Missing \"Content-Type\" header in POST request."; |
| 207 net_headers.SetHeaderIfMissing(HttpRequestHeaders::kContentType, | 207 net_headers.SetHeaderIfMissing(HttpRequestHeaders::kContentType, |
| 208 "application/x-www-form-urlencoded"); | 208 "application/x-www-form-urlencoded"); |
| 209 } | 209 } |
| 210 out_request->SetExtraRequestHeaders(net_headers); | 210 out_request->SetExtraRequestHeaders(net_headers); |
| 211 } | 211 } |
| 212 | 212 |
| 213 } // namespace net | 213 } // namespace net |
| OLD | NEW |