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

Side by Side Diff: Source/core/xmlhttprequest/XMLHttpRequest.cpp

Issue 887693002: Lower Received MIME type when creating a response blob. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 10 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 | « LayoutTests/http/tests/xmlhttprequest/response-blob-mimetype-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) 2004, 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2005-2007 Alexey Proskuryakov <ap@webkit.org> 3 * Copyright (C) 2005-2007 Alexey Proskuryakov <ap@webkit.org>
4 * Copyright (C) 2007, 2008 Julien Chaffraix <jchaffraix@webkit.org> 4 * Copyright (C) 2007, 2008 Julien Chaffraix <jchaffraix@webkit.org>
5 * Copyright (C) 2008, 2011 Google Inc. All rights reserved. 5 * Copyright (C) 2008, 2011 Google Inc. All rights reserved.
6 * Copyright (C) 2012 Intel Corporation 6 * Copyright (C) 2012 Intel Corporation
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public 9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 // data to a file-handle directly in the browser process. We get 430 // data to a file-handle directly in the browser process. We get
431 // the file-path from the ResourceResponse directly instead of 431 // the file-path from the ResourceResponse directly instead of
432 // copying the bytes between the browser and the renderer. 432 // copying the bytes between the browser and the renderer.
433 m_responseBlob = Blob::create(createBlobDataHandleFromResponse()); 433 m_responseBlob = Blob::create(createBlobDataHandleFromResponse());
434 } else { 434 } else {
435 OwnPtr<BlobData> blobData = BlobData::create(); 435 OwnPtr<BlobData> blobData = BlobData::create();
436 size_t size = 0; 436 size_t size = 0;
437 if (m_binaryResponseBuilder && m_binaryResponseBuilder->size()) { 437 if (m_binaryResponseBuilder && m_binaryResponseBuilder->size()) {
438 size = m_binaryResponseBuilder->size(); 438 size = m_binaryResponseBuilder->size();
439 blobData->appendBytes(m_binaryResponseBuilder->data(), size); 439 blobData->appendBytes(m_binaryResponseBuilder->data(), size);
440 blobData->setContentType(finalResponseMIMETypeWithFallback()); 440 blobData->setContentType(finalResponseMIMETypeWithFallback().low er());
441 m_binaryResponseBuilder.clear(); 441 m_binaryResponseBuilder.clear();
442 } 442 }
443 m_responseBlob = Blob::create(BlobDataHandle::create(blobData.releas e(), size)); 443 m_responseBlob = Blob::create(BlobDataHandle::create(blobData.releas e(), size));
444 } 444 }
445 } 445 }
446 446
447 return m_responseBlob.get(); 447 return m_responseBlob.get();
448 } 448 }
449 449
450 DOMArrayBuffer* XMLHttpRequest::responseArrayBuffer() 450 DOMArrayBuffer* XMLHttpRequest::responseArrayBuffer()
(...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after
1510 { 1510 {
1511 ASSERT(m_downloadingToFile); 1511 ASSERT(m_downloadingToFile);
1512 OwnPtr<BlobData> blobData = BlobData::create(); 1512 OwnPtr<BlobData> blobData = BlobData::create();
1513 String filePath = m_response.downloadedFilePath(); 1513 String filePath = m_response.downloadedFilePath();
1514 // If we errored out or got no data, we return an empty handle. 1514 // If we errored out or got no data, we return an empty handle.
1515 if (!filePath.isEmpty() && m_lengthDownloadedToFile) { 1515 if (!filePath.isEmpty() && m_lengthDownloadedToFile) {
1516 blobData->appendFile(filePath); 1516 blobData->appendFile(filePath);
1517 // FIXME: finalResponseMIMETypeWithFallback() defaults to 1517 // FIXME: finalResponseMIMETypeWithFallback() defaults to
1518 // text/xml which may be incorrect. Replace it with 1518 // text/xml which may be incorrect. Replace it with
1519 // finalResponseMIMEType() after compatibility investigation. 1519 // finalResponseMIMEType() after compatibility investigation.
1520 blobData->setContentType(finalResponseMIMETypeWithFallback()); 1520 blobData->setContentType(finalResponseMIMETypeWithFallback().lower());
1521 } 1521 }
1522 return BlobDataHandle::create(blobData.release(), m_lengthDownloadedToFile); 1522 return BlobDataHandle::create(blobData.release(), m_lengthDownloadedToFile);
1523 } 1523 }
1524 1524
1525 void XMLHttpRequest::notifyParserStopped() 1525 void XMLHttpRequest::notifyParserStopped()
1526 { 1526 {
1527 // This should only be called when response document is parsed asynchronousl y. 1527 // This should only be called when response document is parsed asynchronousl y.
1528 ASSERT(m_responseDocumentParser); 1528 ASSERT(m_responseDocumentParser);
1529 ASSERT(!m_responseDocumentParser->isParsing()); 1529 ASSERT(!m_responseDocumentParser->isParsing());
1530 ASSERT(!m_responseLegacyStream); 1530 ASSERT(!m_responseLegacyStream);
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
1802 visitor->trace(m_responseDocumentParser); 1802 visitor->trace(m_responseDocumentParser);
1803 visitor->trace(m_progressEventThrottle); 1803 visitor->trace(m_progressEventThrottle);
1804 visitor->trace(m_upload); 1804 visitor->trace(m_upload);
1805 visitor->trace(m_blobLoader); 1805 visitor->trace(m_blobLoader);
1806 XMLHttpRequestEventTarget::trace(visitor); 1806 XMLHttpRequestEventTarget::trace(visitor);
1807 DocumentParserClient::trace(visitor); 1807 DocumentParserClient::trace(visitor);
1808 ActiveDOMObject::trace(visitor); 1808 ActiveDOMObject::trace(visitor);
1809 } 1809 }
1810 1810
1811 } // namespace blink 1811 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/http/tests/xmlhttprequest/response-blob-mimetype-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698