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 "webkit/appcache/appcache_request_handler.h" | 5 #include "webkit/appcache/appcache_request_handler.h" |
6 | 6 |
7 #include "net/url_request/url_request.h" | 7 #include "net/url_request/url_request.h" |
8 #include "net/url_request/url_request_job.h" | 8 #include "net/url_request/url_request_job.h" |
9 #include "webkit/appcache/appcache.h" | 9 #include "webkit/appcache/appcache.h" |
10 #include "webkit/appcache/appcache_url_request_job.h" | 10 #include "webkit/appcache/appcache_url_request_job.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 // We don't fallback for responses that we delivered. | 130 // We don't fallback for responses that we delivered. |
131 if (job_) { | 131 if (job_) { |
132 DCHECK(!job_->is_delivering_network_response()); | 132 DCHECK(!job_->is_delivering_network_response()); |
133 return NULL; | 133 return NULL; |
134 } | 134 } |
135 | 135 |
136 if (request->status().is_success()) { | 136 if (request->status().is_success()) { |
137 int code_major = request->GetResponseCode() / 100; | 137 int code_major = request->GetResponseCode() / 100; |
138 if (code_major !=4 && code_major != 5) | 138 if (code_major !=4 && code_major != 5) |
139 return NULL; | 139 return NULL; |
| 140 |
| 141 // Servers can override the fallback behavior with a response header. |
| 142 const std::string kFallbackOverrideHeader( |
| 143 "x-chromium-appcache-fallback-override"); |
| 144 const std::string kFallbackOverrideValue( |
| 145 "disallow-fallback"); |
| 146 std::string header_value; |
| 147 request->GetResponseHeaderByName(kFallbackOverrideHeader, &header_value); |
| 148 if (header_value == kFallbackOverrideValue) |
| 149 return NULL; |
140 } | 150 } |
141 | 151 |
142 // 6.9.6, step 4: If this results in a 4xx or 5xx status code | 152 // 6.9.6, step 4: If this results in a 4xx or 5xx status code |
143 // or there were network errors, get the resource of the fallback entry. | 153 // or there were network errors, get the resource of the fallback entry. |
144 job_ = new AppCacheURLRequestJob(request, storage()); | 154 job_ = new AppCacheURLRequestJob(request, storage()); |
145 DeliverAppCachedResponse( | 155 DeliverAppCachedResponse( |
146 found_fallback_entry_, found_cache_id_, found_manifest_url_, | 156 found_fallback_entry_, found_cache_id_, found_manifest_url_, |
147 true, found_fallback_url_); | 157 true, found_fallback_url_); |
148 return job_; | 158 return job_; |
149 } | 159 } |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 if (!host_->associated_cache() || | 344 if (!host_->associated_cache() || |
335 !host_->associated_cache()->is_complete()) { | 345 !host_->associated_cache()->is_complete()) { |
336 DeliverNetworkResponse(); | 346 DeliverNetworkResponse(); |
337 return; | 347 return; |
338 } | 348 } |
339 | 349 |
340 ContinueMaybeLoadSubResource(); | 350 ContinueMaybeLoadSubResource(); |
341 } | 351 } |
342 | 352 |
343 } // namespace appcache | 353 } // namespace appcache |
OLD | NEW |