Changeset 97219 in webkit
- Timestamp:
- Oct 11, 2011 7:26:45 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r97209 r97219 1 2011-10-11 Martin Robinson <mrobinson@igalia.com> 2 3 [Soup] ResourceHandleSoup does not handle encodedBlobData 4 https://bugs.webkit.org/show_bug.cgi?id=52092 5 6 Reviewed by Gustavo Noronha Silva. 7 8 * platform/gtk/Skipped: Unskip tests which are now passing. 9 1 10 2011-10-11 Ryosuke Niwa <rniwa@webkit.org> 2 11 -
trunk/LayoutTests/platform/gtk/Skipped
r97159 r97219 191 191 # This test crashes whatever test follows it. Perhaps it's related to the previous failure. 192 192 fast/dom/gc-10.html 193 194 # https://bugs.webkit.org/show_bug.cgi?id=54234195 fast/files/apply-blob-url-to-xhr.html196 193 197 194 # https://bugs.webkit.org/show_bug.cgi?id=50744 … … 392 389 fast/filesystem 393 390 http/tests/filesystem 394 http/tests/local/fileapi395 391 http/tests/security/filesystem-iframe-from-remote.html 396 http/tests/websocket/tests/hybi/send-file-blob.html397 http/tests/websocket/tests/hybi/send-file-blob-fail.html398 392 399 393 # Requires WebP support. … … 1316 1310 fast/files/workers/worker-apply-blob-url-to-xhr.html 1317 1311 1318 # [Soup] ResourceHandleSoup does not handle encodedBlobData1319 # https://bugs.webkit.org/show_bug.cgi?id=520921320 http/tests/local/blob/send-data-blob.html1321 http/tests/local/blob/send-hybrid-blob.html1322 http/tests/local/blob/send-sliced-data-blob.html1323 http/tests/local/formdata/send-form-data-with-sliced-file.html1324 1325 1312 # [GTK] Dragging images and links results in a DataTransfer object containing a non-empty files array 1326 1313 # https://bugs.webkit.org/show_bug.cgi?id=52094 … … 1690 1677 # https://bugs.webkit.org/show_bug.cgi?id=69587 1691 1678 editing/pasteboard/smart-paste-008.html 1679 1680 # Some tests fail with "FAIL Unexpected response data received: Wrong method: GET" 1681 # https://bugs.webkit.org/show_bug.cgi?id=69219 1682 http/tests/local/fileapi/send-sliced-dragged-file.html 1683 http/tests/local/blob/send-hybrid-blob.html -
trunk/Source/WebCore/ChangeLog
r97214 r97219 1 2011-10-11 Martin Robinson <mrobinson@igalia.com> 2 3 [Soup] ResourceHandleSoup does not handle encodedBlobData 4 https://bugs.webkit.org/show_bug.cgi?id=52092 5 6 Reviewed by Gustavo Noronha Silva. 7 8 Add support for sending encoded blob data during requests. 9 10 * platform/network/soup/ResourceHandleSoup.cpp: 11 (WebCore::addFileToSoupMessageBody): Added this helper. 12 (WebCore::blobIsOutOfDate): Ditto. 13 (WebCore::addEncodedBlobItemToSoupMessageBody): Ditto. 14 (WebCore::addEncodedBlobToSoupMessageBody): Ditto. 15 (WebCore::addFormElementsToSoupMessage): No longer flatten form data, as we 16 cannot do this in the case where the form data contains blobs. Now handle 17 the blob case. 18 (WebCore::loadResourceSynchronously): Add blob support for synchronous loading. 19 1 20 2011-10-11 Chris Rogers <crogers@google.com> 2 21 -
trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp
r96715 r97219 59 59 #include <wtf/text/CString.h> 60 60 61 #if ENABLE(BLOB) 62 #include "BlobData.h" 63 #include "BlobRegistryImpl.h" 64 #include "BlobStorageData.h" 65 #endif 66 61 67 namespace WebCore { 62 68 … … 515 521 } 516 522 523 static bool addFileToSoupMessageBody(SoupMessage* message, const String& fileNameString, size_t offset, size_t lengthToSend, unsigned long& totalBodySize) 524 { 525 GOwnPtr<GError> error; 526 CString fileName = fileSystemRepresentation(fileNameString); 527 GMappedFile* fileMapping = g_mapped_file_new(fileName.data(), false, &error.outPtr()); 528 if (error) 529 return false; 530 531 gsize bufferLength = lengthToSend; 532 if (!lengthToSend) 533 bufferLength = g_mapped_file_get_length(fileMapping); 534 totalBodySize += bufferLength; 535 536 SoupBuffer* soupBuffer = soup_buffer_new_with_owner(g_mapped_file_get_contents(fileMapping) + offset, 537 bufferLength, 538 fileMapping, 539 reinterpret_cast<GDestroyNotify>(g_mapped_file_unref)); 540 soup_message_body_append_buffer(message->request_body, soupBuffer); 541 soup_buffer_free(soupBuffer); 542 return true; 543 } 544 545 #if ENABLE(BLOB) 546 static bool blobIsOutOfDate(const BlobDataItem& blobItem) 547 { 548 ASSERT(blobItem.type == BlobDataItem::File); 549 if (blobItem.expectedModificationTime == BlobDataItem::doNotCheckFileChange) 550 return false; 551 552 time_t fileModificationTime; 553 if (!getFileModificationTime(blobItem.path, fileModificationTime)) 554 return true; 555 556 return fileModificationTime != static_cast<time_t>(blobItem.expectedModificationTime); 557 } 558 559 static bool addEncodedBlobItemToSoupMessageBody(SoupMessage* message, const BlobDataItem& blobItem, unsigned long& totalBodySize) 560 { 561 if (blobItem.type == BlobDataItem::Data) { 562 totalBodySize += blobItem.length; 563 soup_message_body_append(message->request_body, SOUP_MEMORY_TEMPORARY, 564 blobItem.data->data() + blobItem.offset, blobItem.length); 565 return true; 566 } 567 568 ASSERT(blobItem.type == BlobDataItem::File); 569 if (blobIsOutOfDate(blobItem)) 570 return false; 571 572 return addFileToSoupMessageBody(message, 573 blobItem.path, 574 blobItem.offset, 575 blobItem.length == BlobDataItem::toEndOfFile ? 0 : blobItem.length, 576 totalBodySize); 577 } 578 579 static bool addEncodedBlobToSoupMessageBody(SoupMessage* message, const FormDataElement& element, unsigned long& totalBodySize) 580 { 581 RefPtr<BlobStorageData> blobData = static_cast<BlobRegistryImpl&>(blobRegistry()).getBlobDataFromURL(KURL(ParsedURLString, element.m_blobURL)); 582 if (!blobData) 583 return true; 584 585 for (size_t i = 0; i < blobData->items().size(); ++i) 586 if (!addEncodedBlobItemToSoupMessageBody(message, blobData->items()[i], totalBodySize)) 587 return false; 588 589 return true; 590 } 591 #endif // ENABLE(BLOB) 592 517 593 static bool addFormElementsToSoupMessage(SoupMessage* message, const char* contentType, FormData* httpBody, unsigned long& totalBodySize) 518 594 { 595 soup_message_body_set_accumulate(message->request_body, FALSE); 519 596 size_t numElements = httpBody->elements().size(); 520 if (numElements < 2) { // No file upload is the most common case.521 Vector<char> body;522 httpBody->flatten(body);523 totalBodySize = body.size();524 soup_message_set_request(message, contentType, SOUP_MEMORY_COPY, body.data(), body.size());525 return true;526 }527 528 // We have more than one element to upload, and some may be large files,529 // which we will want to mmap instead of copying into memory530 soup_message_body_set_accumulate(message->request_body, FALSE);531 597 for (size_t i = 0; i < numElements; i++) { 532 598 const FormDataElement& element = httpBody->elements()[i]; … … 539 605 } 540 606 541 // This technique is inspired by libsoup's simple-httpd test. 542 GOwnPtr<GError> error; 543 CString fileName = fileSystemRepresentation(element.m_filename); 544 GMappedFile* fileMapping = g_mapped_file_new(fileName.data(), false, &error.outPtr()); 545 if (error) 607 if (element.m_type == FormDataElement::encodedFile) { 608 if (!addFileToSoupMessageBody(message , 609 element.m_filename, 610 0 /* offset */, 611 0 /* lengthToSend */, 612 totalBodySize)) 613 return false; 614 continue; 615 } 616 617 #if ENABLE(BLOB) 618 ASSERT(element.m_type == FormDataElement::encodedBlob); 619 if (!addEncodedBlobToSoupMessageBody(message, element, totalBodySize)) 546 620 return false; 547 548 gsize mappedFileSize = g_mapped_file_get_length(fileMapping); 549 totalBodySize += mappedFileSize; 550 SoupBuffer* soupBuffer = soup_buffer_new_with_owner(g_mapped_file_get_contents(fileMapping), 551 mappedFileSize, fileMapping, 552 reinterpret_cast<GDestroyNotify>(g_mapped_file_unref)); 553 soup_message_body_append_buffer(message->request_body, soupBuffer); 554 soup_buffer_free(soupBuffer); 555 } 556 621 #endif 622 } 557 623 return true; 558 624 } … … 731 797 void ResourceHandle::loadResourceSynchronously(NetworkingContext* context, const ResourceRequest& request, StoredCredentials /*storedCredentials*/, ResourceError& error, ResourceResponse& response, Vector<char>& data) 732 798 { 799 #if ENABLE(BLOB) 800 if (request.url().protocolIs("blob")) { 801 blobRegistry().loadResourceSynchronously(request, error, response, data); 802 return; 803 } 804 #endif 805 733 806 WebCoreSynchronousLoader syncLoader(error, response, data); 734 807 RefPtr<ResourceHandle> handle = create(context, request, &syncLoader, false /*defersLoading*/, false /*shouldContentSniff*/);
Note: See TracChangeset
for help on using the changeset viewer.