Changeset 77408 in webkit
- Timestamp:
- Feb 2, 2011 1:19:41 PM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r77407 r77408 1 2011-02-02 Dan Winship <danw@gnome.org> 2 3 Reviewed by Martin Robinson. 4 5 [GTK] remove old data: URI handler, fix the SoupRequest-based one 6 to pass tests 7 https://bugs.webkit.org/show_bug.cgi?id=50885 8 9 * platform/network/soup/ResourceHandleSoup.cpp: 10 (WebCore::sendRequestCallback): Do content-type sniffing here for 11 non-HTTP requests. 12 (WebCore::startHTTPRequest): Rename to match WebKit style. 13 (WebCore::ResourceHandle::start): Pass everything except HTTP to 14 startNonHTTPRequest, letting the SoupRequester decide whether it's 15 supported or not. 16 (WebCore::startNonHTTPRequest): Remove some old pre-SoupRequester 17 code that was a no-op for file: URIs, but would break some data: 18 URIs. 19 1 20 2011-02-02 Dimitri Glazkov <dglazkov@chromium.org> 2 21 -
trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp
r77399 r77408 130 130 static void readCallback(GObject*, GAsyncResult*, gpointer); 131 131 static void closeCallback(GObject*, GAsyncResult*, gpointer); 132 static bool start Gio(ResourceHandle*, KURL);132 static bool startNonHTTPRequest(ResourceHandle*, KURL); 133 133 134 134 ResourceHandleInternal::~ResourceHandleInternal() … … 298 298 } 299 299 300 // This callback will not be called if the content sniffer is disabled in startH ttp.300 // This callback will not be called if the content sniffer is disabled in startHTTPRequest. 301 301 static void contentSniffedCallback(SoupMessage* msg, const char* sniffedType, GHashTable *params, gpointer data) 302 302 { … … 345 345 346 346 client->didReceiveData(handle.get(), chunk->data, chunk->length, false); 347 }348 349 static gboolean parseDataUrl(gpointer callbackData)350 {351 ResourceHandle* handle = static_cast<ResourceHandle*>(callbackData);352 ResourceHandleClient* client = handle->client();353 ResourceHandleInternal* d = handle->getInternal();354 if (d->m_cancelled)355 return false;356 357 d->m_idleHandler = 0;358 359 ASSERT(client);360 if (!client)361 return false;362 363 String url = handle->firstRequest().url().string();364 ASSERT(url.startsWith("data:", false));365 366 int index = url.find(',');367 if (index == -1) {368 client->cannotShowURL(handle);369 return false;370 }371 372 String mediaType = url.substring(5, index - 5);373 374 bool isBase64 = mediaType.endsWith(";base64", false);375 if (isBase64)376 mediaType = mediaType.left(mediaType.length() - 7);377 378 if (mediaType.isEmpty())379 mediaType = "text/plain;charset=US-ASCII";380 381 String mimeType = extractMIMETypeFromMediaType(mediaType);382 String charset = extractCharsetFromMediaType(mediaType);383 384 ASSERT(d->m_response.isNull());385 386 d->m_response.setURL(handle->firstRequest().url());387 d->m_response.setMimeType(mimeType);388 389 // For non base64 encoded data we have to convert to UTF-16 early390 // due to limitations in KURL391 d->m_response.setTextEncodingName(isBase64 ? charset : "UTF-16");392 client->didReceiveResponse(handle, d->m_response);393 394 // The load may be cancelled, and the client may be destroyed395 // by any of the client reporting calls, so we check, and bail396 // out in either of those cases.397 if (d->m_cancelled || !handle->client())398 return false;399 400 SoupSession* session = handle->defaultSession();401 ensureSessionIsInitialized(session);402 SoupRequester* requester = SOUP_REQUESTER(soup_session_get_feature(session, SOUP_TYPE_REQUESTER));403 GOwnPtr<GError> error;404 d->m_soupRequest = adoptGRef(soup_requester_request(requester, handle->firstRequest().url().string().utf8().data(), &error.outPtr()));405 if (error) {406 d->m_soupRequest = 0;407 client->didFinishLoading(handle, 0);408 return false;409 }410 411 d->m_inputStream = adoptGRef(soup_request_send(d->m_soupRequest.get(), 0, &error.outPtr()));412 if (error) {413 d->m_inputStream = 0;414 client->didFinishLoading(handle, 0);415 return false;416 }417 418 d->m_buffer = static_cast<char*>(g_slice_alloc0(READ_BUFFER_SIZE));419 d->m_total = 0;420 421 g_object_set_data(G_OBJECT(d->m_inputStream.get()), "webkit-resource", handle);422 // balanced by a deref() in cleanupSoupRequestOperation, which should always run423 handle->ref();424 425 d->m_cancellable = adoptGRef(g_cancellable_new());426 g_input_stream_read_async(d->m_inputStream.get(), d->m_buffer, READ_BUFFER_SIZE, G_PRIORITY_DEFAULT,427 d->m_cancellable.get(), readCallback, GINT_TO_POINTER(!isBase64));428 429 return false;430 }431 432 static bool startData(ResourceHandle* handle, String urlString)433 {434 ASSERT(handle);435 436 ResourceHandleInternal* d = handle->getInternal();437 438 // If parseDataUrl is called synchronously the job is not yet effectively started439 // and webkit won't never know that the data has been parsed even didFinishLoading is called.440 d->m_idleHandler = g_timeout_add(0, parseDataUrl, handle);441 return true;442 347 } 443 348 … … 555 460 g_object_set_data(G_OBJECT(d->m_inputStream.get()), "webkit-resource", handle.get()); 556 461 557 // Ensure a response is sent for any protocols that don't explicitly support responses 558 // through got-headers signal or content sniffing. 559 // (e.g. file and GIO based protocol). 560 if (!handle->shouldContentSniff() && d->m_response.isNull()) { 462 // If not using SoupMessage we need to call didReceiveResponse now. 463 // (This will change later when SoupRequest supports content sniffing.) 464 if (!d->m_soupMessage) { 561 465 d->m_response.setURL(handle->firstRequest().url()); 562 d->m_response.setMimeType(soup_request_get_content_type(d->m_soupRequest.get())); 466 const gchar* contentType = soup_request_get_content_type(d->m_soupRequest.get()); 467 d->m_response.setMimeType(extractMIMETypeFromMediaType(contentType)); 468 d->m_response.setTextEncodingName(extractCharsetFromMediaType(contentType)); 563 469 d->m_response.setExpectedContentLength(soup_request_get_content_length(d->m_soupRequest.get())); 564 470 client->didReceiveResponse(handle.get(), d->m_response); … … 577 483 } 578 484 579 static bool startH ttp(ResourceHandle* handle)485 static bool startHTTPRequest(ResourceHandle* handle) 580 486 { 581 487 ASSERT(handle); … … 719 625 d->m_context = context; 720 626 721 if (equalIgnoringCase(protocol, "data"))722 return startData(this, urlString);723 724 627 if (equalIgnoringCase(protocol, "http") || equalIgnoringCase(protocol, "https")) { 725 if (startH ttp(this))628 if (startHTTPRequest(this)) 726 629 return true; 727 630 } 728 631 729 if (equalIgnoringCase(protocol, "file") || equalIgnoringCase(protocol, "ftp") || equalIgnoringCase(protocol, "ftps")) { 730 // FIXME: should we be doing any other protocols here? 731 if (startGio(this, url)) 732 return true; 733 } 632 if (startNonHTTPRequest(this, url)) 633 return true; 734 634 735 635 // Error must not be reported immediately … … 881 781 } 882 782 883 static bool start Gio(ResourceHandle* handle, KURL url)783 static bool startNonHTTPRequest(ResourceHandle* handle, KURL url) 884 784 { 885 785 ASSERT(handle); … … 893 793 ResourceHandleInternal* d = handle->getInternal(); 894 794 895 // GIO doesn't know how to handle refs and queries, so remove them896 // TODO: use KURL.fileSystemPath after KURLGtk and FileSystemGtk are897 // using GIO internally, and providing URIs instead of file paths898 url.removeFragmentIdentifier();899 url.setQuery(String());900 url.removePort();901 795 CString urlStr = url.string().utf8(); 902 796
Note: See TracChangeset
for help on using the changeset viewer.