jint WebCoreResourceLoader::CreateResponse(JNIEnv* env, jobject obj, jstring url, jint statusCode,
                                                    jstring statusText, jstring mimeType, jlong expectedLength,
                                                    jstring encoding)
{
#ifdef ANDROID_INSTRUMENT
    TimeCounterAuto counter(TimeCounter::ResourceTimeCounter);
#endif
    LOG_ASSERT(url, "Must have a url in the response!");
    WebCore::KURL kurl(WebCore::ParsedURLString, to_string(env, url));
    WebCore::String encodingStr;
    WebCore::String mimeTypeStr;
    if (mimeType) {
        mimeTypeStr = to_string(env, mimeType);
        LOGV("Response setMIMEType: %s", mimeTypeStr.latin1().data());
    }
    if (encoding) {
        encodingStr = to_string(env, encoding);
        LOGV("Response setTextEncodingName: %s", encodingStr.latin1().data());
    }
    WebCore::ResourceResponse* response = new WebCore::ResourceResponse(
            kurl, mimeTypeStr, (long long)expectedLength,
            encodingStr, WebCore::String());
    response->setHTTPStatusCode(statusCode);
    if (statusText) {
        WebCore::String status = to_string(env, statusText);
        response->setHTTPStatusText(status);
        LOGV("Response setStatusText: %s", status.latin1().data());
    }
    return (int)response;
}
void CustomProtocolManagerImpl::didReceiveResponse(uint64_t customProtocolID, const WebCore::ResourceResponse& response)
{
    WebSoupRequestAsyncData* data = m_customProtocolMap.get(customProtocolID);
    ASSERT(data);
    ASSERT(data->task);

    WebKitSoupRequestGeneric* request = WEBKIT_SOUP_REQUEST_GENERIC(g_task_get_source_object(data->task));
    webkitSoupRequestGenericSetContentLength(request, response.expectedContentLength() ? response.expectedContentLength() : -1);
    webkitSoupRequestGenericSetContentType(request, !response.mimeType().isEmpty() ? response.mimeType().utf8().data() : 0);
}
/**
 * webkit_network_response_get_suggested_filename:
 * @response: a #WebKitNetworkResponse
 *
 * Obtains the suggested filename for the given network response. The
 * suggested filename is taken from the 'Content-Disposition' HTTP
 * header, but this is not always present, and this method will return
 * %NULL in such case.
 *
 * Returns: (transfer none): the suggested filename or %NULL if not present
 * Since: 1.10
 **/
const gchar* webkit_network_response_get_suggested_filename(WebKitNetworkResponse* response)
{
    g_return_val_if_fail(WEBKIT_IS_NETWORK_RESPONSE(response), 0);

    WebKitNetworkResponsePrivate* priv = response->priv;

    if (priv->suggestedFilename)
        return priv->suggestedFilename;

    WebCore::ResourceResponse coreResponse = core(response);
    priv->suggestedFilename = g_strdup(coreResponse.suggestedFilename().utf8().data());
    return priv->suggestedFilename;
}
// ----------------------------------------------------------------------------
void WebCoreResourceLoader::SetResponseHeader(JNIEnv* env, jobject obj, jint nativeResponse, jstring key, jstring val)
{
#ifdef ANDROID_INSTRUMENT
    TimeCounterAuto counter(TimeCounter::ResourceTimeCounter);
#endif
    
    WebCore::ResourceResponse* response = (WebCore::ResourceResponse*)nativeResponse;
    LOG_ASSERT(response, "nativeSetResponseHeader must take a valid response pointer!");

    LOG_ASSERT(key, "How did a null value become a key?");
    if (val) {
        WebCore::String valStr = to_string(env, val);
        if (!valStr.isEmpty())
            response->setHTTPHeaderField(to_string(env, key), valStr);
    }
}
void NetworkResourceLoader::sharedWillSendRedirectedRequest(const WebCore::ResourceRequest& request, const WebCore::ResourceResponse& redirectResponse)
{
    // We only expect to get the willSendRequest callback from ResourceHandle as the result of a redirect.
    ASSERT(!redirectResponse.isNull());
    ASSERT(RunLoop::isMain());

    m_currentRequest = request;

#if ENABLE(NETWORK_CACHE)
    WebCore::updateRedirectChainStatus(m_redirectChainCacheStatus, redirectResponse);
#endif

    if (isSynchronous()) {
        // FIXME: This needs to be fixed to follow the redirect correctly even for cross-domain requests.
        // This includes at least updating host records, and comparing the current request instead of the original request here.
        if (!protocolHostAndPortAreEqual(originalRequest().url(), m_currentRequest.url())) {
            ASSERT(m_synchronousLoadData->error.isNull());
            m_synchronousLoadData->error = SynchronousLoaderClient::platformBadResponseError();
            m_currentRequest = ResourceRequest();
        }
        continueWillSendRequest(m_currentRequest);
        return;
    }
    sendAbortingOnFailure(Messages::WebResourceLoader::WillSendRequest(m_currentRequest, redirectResponse));
}
Exemple #6
0
static QString drtDescriptionSuitableForTestResult(const WebCore::ResourceResponse& response)
{
    QString text = response.httpStatusText();
    if (text.isEmpty())
        return QLatin1String("(null)");

    return text;
}
Exemple #7
0
void DumpRenderTree::didDecidePolicyForResponse(const WebCore::ResourceResponse& response)
{
    if (!testDone && m_policyDelegateEnabled) {
        if (WebCore::contentDispositionType(response.httpHeaderField("Content-Disposition")) == WebCore::ContentDispositionAttachment)
            printf("Policy delegate: resource is an attachment, suggested file name '%s'\n", response.suggestedFilename().utf8().data());
        if (waitForPolicy)
            gTestRunner->notifyDone();
    }
}
Exemple #8
0
void encodeResourceResponse(ArgumentEncoder* encoder, const WebCore::ResourceResponse& resourceResponse)
{
#if USE(CFNETWORK)
    bool responseIsPresent = resourceResponse.cfURLResponse();
    encoder->encode(responseIsPresent);

    if (!responseIsPresent)
        return;

    RetainPtr<CFDictionaryRef> dictionary(AdoptCF, wkCFURLResponseCreateSerializableRepresentation(resourceResponse.cfURLResponse(), CoreIPC::tokenNullTypeRef()));
    encode(encoder, dictionary.get());
#endif
}
void FrameLoaderClientQt::dispatchWillSendRequest(WebCore::DocumentLoader*, unsigned long identifier, WebCore::ResourceRequest& newRequest, const WebCore::ResourceResponse& redirectResponse)
{

    if (dumpResourceLoadCallbacks)
        printf("%s - willSendRequest %s redirectResponse %s\n",
               qPrintable(dumpAssignedUrls[identifier]),
               qPrintable(drtDescriptionSuitableForTestResult(newRequest)),
               (redirectResponse.isNull()) ? "(null)" : qPrintable(drtDescriptionSuitableForTestResult(redirectResponse)));

    if (sendRequestReturnsNull)
        newRequest.setURL(QUrl());

    if (sendRequestReturnsNullOnRedirect && !redirectResponse.isNull()) {
        printf("Returning null for this redirect\n");
        newRequest.setURL(QUrl());
    }

    for (int i = 0; i < sendRequestClearHeaders.size(); ++i)
          newRequest.setHTTPHeaderField(sendRequestClearHeaders.at(i).toLocal8Bit().constData(), QString());

    // seems like the Mac code doesn't do anything here by default neither
    //qDebug() << "FrameLoaderClientQt::dispatchWillSendRequest" << request.isNull() << request.url().string`();
}
WebCore::ResourceError FrameLoaderClientWx::fileDoesNotExistError(const WebCore::ResourceResponse& response)
{
    notImplemented();
    return ResourceError(String(), WebKitErrorCannotShowURL, response.url().string(), String());
}
WebCore::ResourceError FrameLoaderClientWx::cannotShowMIMETypeError(const WebCore::ResourceResponse& response)
{
    notImplemented();
    return ResourceError(String(), WebKitErrorCannotShowMIMEType, response.url().string(), String());
}
Exemple #12
0
WebCore::ResourceError FrameLoaderClientQt::fileDoesNotExistError(const WebCore::ResourceResponse& response)
{
    return ResourceError("QtNetwork", QNetworkReply::ContentNotFoundError, response.url().string(),
            QCoreApplication::translate("QWebFrame", "File does not exist", 0, QCoreApplication::UnicodeUTF8));
}
Exemple #13
0
WebCore::ResourceError FrameLoaderClientQt::cannotShowMIMETypeError(const WebCore::ResourceResponse& response)
{
    return ResourceError("WebKit", WebKitErrorCannotShowMIMEType, response.url().string(),
            QCoreApplication::translate("QWebFrame", "Cannot show mimetype", 0, QCoreApplication::UnicodeUTF8));
}
Exemple #14
0
WebCore::ResourceError FrameLoaderClientQt::fileDoesNotExistError(const WebCore::ResourceResponse& response)
{
    return ResourceError("Error", -998 /* ### */, response.url().string(),
            QCoreApplication::translate("QWebFrame", "File does not exist", 0, QCoreApplication::UnicodeUTF8));
}
Exemple #15
0
void DumpRenderTree::didReceiveResponseForFrame(WebCore::Frame*, const WebCore::ResourceResponse& response)
{
    if (!testDone && gTestRunner->dumpResourceResponseMIMETypes())
        printf("%s has MIME type %s\n", response.url().lastPathComponent().utf8().data(), response.mimeType().utf8().data());
}
static QString drtDescriptionSuitableForTestResult(const WebCore::ResourceResponse& response)
{
    QString url = response.url().string();
    int httpStatusCode = response.httpStatusCode();
    return QString::fromLatin1("<NSURLResponse %1, http status code %2>").arg(url).arg(httpStatusCode);
}