Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(614)

Side by Side Diff: third_party/WebKit/Source/core/fetch/ResourceLoader.cpp

Issue 1558703002: Synchronous requests that get a 304 clobber the cached response body. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add comment Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/cache/sync-xhr-304-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2010, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2010, 2011 Apple Inc. All rights reserved.
3 * (C) 2007 Graham Dennis (graham.dennis@gmail.com) 3 * (C) 2007 Graham Dennis (graham.dennis@gmail.com)
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 return; 508 return;
509 } 509 }
510 didFail(0, errorOut); 510 didFail(0, errorOut);
511 return; 511 return;
512 } 512 }
513 didReceiveResponse(0, responseOut); 513 didReceiveResponse(0, responseOut);
514 if (m_state == Terminated) 514 if (m_state == Terminated)
515 return; 515 return;
516 RefPtr<ResourceLoadInfo> resourceLoadInfo = responseOut.toResourceResponse() .resourceLoadInfo(); 516 RefPtr<ResourceLoadInfo> resourceLoadInfo = responseOut.toResourceResponse() .resourceLoadInfo();
517 int64_t encodedDataLength = resourceLoadInfo ? resourceLoadInfo->encodedData Length : WebURLLoaderClient::kUnknownEncodedDataLength; 517 int64_t encodedDataLength = resourceLoadInfo ? resourceLoadInfo->encodedData Length : WebURLLoaderClient::kUnknownEncodedDataLength;
518 m_fetcher->didReceiveData(m_resource, dataOut.data(), dataOut.size(), encode dDataLength); 518
519 m_resource->setResourceBuffer(dataOut); 519 // Follow the async case convention of not calling didReceiveData or
520 // appending data to m_resource if the response body is empty. Copying the
521 // empty buffer is a noop in most cases, but is destructive in the case of
522 // a 304, where it will overwrite the cached data we should be reusing.
523 if (dataOut.size()) {
524 m_fetcher->didReceiveData(m_resource, dataOut.data(), dataOut.size(), en codedDataLength);
525 m_resource->setResourceBuffer(dataOut);
526 }
520 didFinishLoading(0, monotonicallyIncreasingTime(), encodedDataLength); 527 didFinishLoading(0, monotonicallyIncreasingTime(), encodedDataLength);
521 } 528 }
522 529
523 ResourceRequest& ResourceLoader::applyOptions(ResourceRequest& request) const 530 ResourceRequest& ResourceLoader::applyOptions(ResourceRequest& request) const
524 { 531 {
525 request.setAllowStoredCredentials(m_options.allowCredentials == AllowStoredC redentials); 532 request.setAllowStoredCredentials(m_options.allowCredentials == AllowStoredC redentials);
526 return request; 533 return request;
527 } 534 }
528 535
529 } 536 }
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/cache/sync-xhr-304-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698