Changeset 272138 in webkit
- Timestamp:
- Feb 1, 2021, 2:29:36 AM (6 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 3 edited
-
ChangeLog (modified) (1 diff)
-
NetworkProcess/soup/NetworkDataTaskSoup.cpp (modified) (5 diffs)
-
NetworkProcess/soup/NetworkDataTaskSoup.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r272122 r272138 1 2021-02-01 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [SOUP] Add support for data URLs in the network process 4 https://bugs.webkit.org/show_bug.cgi?id=221127 5 6 Reviewed by Adrian Perez de Castro. 7 8 In r271879 I removed the support for data URLs in the network process for soup, assuming data URLs were always 9 loaded from the web process, but that's not the case for downloads. I think we should not go to the network 10 process for downloads either, but for now it's easier to fix this regression by supporting data URLs in the 11 network process again. Fixes http/tests/security/anchor-download-allow-data.html. 12 13 * NetworkProcess/soup/NetworkDataTaskSoup.cpp: 14 (WebKit::NetworkDataTaskSoup::createRequest): Return early if it's a data URL. 15 (WebKit::NetworkDataTaskSoup::clearRequest): Clear the pending data URL result. 16 (WebKit::NetworkDataTaskSoup::resume): Start a data URL decode task if it's a new data URL request, or complete 17 the pending one. 18 (WebKit::NetworkDataTaskSoup::didReadDataURL): Complete the data URL request. 19 * NetworkProcess/soup/NetworkDataTaskSoup.h: 20 1 21 2021-01-29 Darin Adler <darin@apple.com> 2 22 -
trunk/Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.cpp
r272010 r272138 114 114 } 115 115 116 if (m_currentRequest.url().protocolIsData()) 117 return; 118 116 119 if (!m_currentRequest.url().protocolIsInHTTPFamily()) { 117 120 scheduleFailure(InvalidURLFailure); … … 192 195 stopTimeout(); 193 196 m_pendingResult = nullptr; 197 m_pendingDataURLResult = WTF::nullopt; 194 198 m_file = nullptr; 195 199 m_inputStream = nullptr; … … 239 243 g_file_query_info_async(m_file.get(), G_FILE_ATTRIBUTE_STANDARD_TYPE "," G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE "," G_FILE_ATTRIBUTE_STANDARD_SIZE, 240 244 G_FILE_QUERY_INFO_NONE, RunLoopSourcePriority::AsyncIONetwork, m_cancellable.get(), reinterpret_cast<GAsyncReadyCallback>(fileQueryInfoCallback), protectedThis.leakRef()); 245 return; 246 } 247 248 if (m_currentRequest.url().protocolIsData() && !m_cancellable) { 249 m_cancellable = adoptGRef(g_cancellable_new()); 250 DataURLDecoder::decode(m_currentRequest.url(), { }, DataURLDecoder::Mode::Legacy, [this, protectedThis = WTFMove(protectedThis)](auto decodeResult) mutable { 251 if (m_state == State::Canceling || m_state == State::Completed || !m_client) { 252 clearRequest(); 253 return; 254 } 255 256 if (m_state == State::Suspended) { 257 m_pendingDataURLResult = WTFMove(decodeResult); 258 return; 259 } 260 261 didReadDataURL(WTFMove(decodeResult)); 262 }); 241 263 return; 242 264 } … … 258 280 } else 259 281 ASSERT_NOT_REACHED(); 260 } 282 } else if (m_currentRequest.url().protocolIsData()) 283 didReadDataURL(WTFMove(m_pendingDataURLResult)); 261 284 } 262 285 … … 1298 1321 } 1299 1322 1323 void NetworkDataTaskSoup::didReadDataURL(Optional<DataURLDecoder::Result>&& result) 1324 { 1325 if (g_cancellable_is_cancelled(m_cancellable.get())) { 1326 didFail(cancelledError(m_currentRequest)); 1327 return; 1328 } 1329 1330 if (!result) { 1331 didFail(internalError(m_currentRequest.url())); 1332 return; 1333 } 1334 1335 m_response = ResourceResponse::dataURLResponse(m_currentRequest.url(), result.value()); 1336 auto bytes = SharedBuffer::create(WTFMove(result->data))->createGBytes(); 1337 m_inputStream = adoptGRef(g_memory_input_stream_new_from_bytes(bytes.get())); 1338 dispatchDidReceiveResponse(); 1339 } 1340 1300 1341 } // namespace WebKit 1301 1342 -
trunk/Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.h
r272010 r272138 27 27 28 28 #include "NetworkDataTask.h" 29 #include <WebCore/DataURLDecoder.h> 29 30 #include <WebCore/FrameIdentifier.h> 30 31 #include <WebCore/NetworkLoadMetrics.h> … … 143 144 void didReadFile(GRefPtr<GInputStream>&&); 144 145 146 void didReadDataURL(Optional<WebCore::DataURLDecoder::Result>&&); 147 145 148 WebCore::FrameIdentifier m_frameID; 146 149 WebCore::PageIdentifier m_pageID; … … 153 156 GRefPtr<GCancellable> m_cancellable; 154 157 GRefPtr<GAsyncResult> m_pendingResult; 158 Optional<WebCore::DataURLDecoder::Result> m_pendingDataURLResult; 155 159 WebCore::ProtectionSpace m_protectionSpaceForPersistentStorage; 156 160 WebCore::Credential m_credentialForPersistentStorage;
Note:
See TracChangeset
for help on using the changeset viewer.