예제 #1
0
void ResourceRequest::doUpdatePlatformRequest()
{
    CFMutableURLRequestRef cfRequest;

    RetainPtr<CFURLRef> url(AdoptCF, ResourceRequest::url().createCFURL());
    RetainPtr<CFURLRef> firstPartyForCookies(AdoptCF, ResourceRequest::firstPartyForCookies().createCFURL());
    if (m_cfRequest) {
        cfRequest = CFURLRequestCreateMutableCopy(0, m_cfRequest.get());
        CFURLRequestSetURL(cfRequest, url.get());
        CFURLRequestSetMainDocumentURL(cfRequest, firstPartyForCookies.get());
        CFURLRequestSetCachePolicy(cfRequest, (CFURLRequestCachePolicy)cachePolicy());
        CFURLRequestSetTimeoutInterval(cfRequest, timeoutInterval());
    } else
        cfRequest = CFURLRequestCreateMutable(0, url.get(), (CFURLRequestCachePolicy)cachePolicy(), timeoutInterval(), firstPartyForCookies.get());
#if USE(CFURLSTORAGESESSIONS)
    wkSetRequestStorageSession(ResourceHandle::currentStorageSession(), cfRequest);
#endif

    RetainPtr<CFStringRef> requestMethod(AdoptCF, httpMethod().createCFString());
    CFURLRequestSetHTTPRequestMethod(cfRequest, requestMethod.get());

    if (httpPipeliningEnabled())
        wkSetHTTPPipeliningPriority(cfRequest, toHTTPPipeliningPriority(m_priority));

    setHeaderFields(cfRequest, httpHeaderFields());
    WebCore::setHTTPBody(cfRequest, httpBody());
    CFURLRequestSetShouldHandleHTTPCookies(cfRequest, allowCookies());

    unsigned fallbackCount = m_responseContentDispositionEncodingFallbackArray.size();
    RetainPtr<CFMutableArrayRef> encodingFallbacks(AdoptCF, CFArrayCreateMutable(kCFAllocatorDefault, fallbackCount, 0));
    for (unsigned i = 0; i != fallbackCount; ++i) {
        RetainPtr<CFStringRef> encodingName(AdoptCF, m_responseContentDispositionEncodingFallbackArray[i].createCFString());
        CFStringEncoding encoding = CFStringConvertIANACharSetNameToEncoding(encodingName.get());
        if (encoding != kCFStringEncodingInvalidId)
            CFArrayAppendValue(encodingFallbacks.get(), reinterpret_cast<const void*>(encoding));
    }
    setContentDispositionEncodingFallbackArray(cfRequest, encodingFallbacks.get());

    if (m_cfRequest) {
        RetainPtr<CFHTTPCookieStorageRef> cookieStorage(AdoptCF, CFURLRequestCopyHTTPCookieStorage(m_cfRequest.get()));
        if (cookieStorage)
            CFURLRequestSetHTTPCookieStorage(cfRequest, cookieStorage.get());
        CFURLRequestSetHTTPCookieStorageAcceptPolicy(cfRequest, CFURLRequestGetHTTPCookieStorageAcceptPolicy(m_cfRequest.get()));
        CFURLRequestSetSSLProperties(cfRequest, CFURLRequestGetSSLProperties(m_cfRequest.get()));
    }

    m_cfRequest.adoptCF(cfRequest);
#if PLATFORM(MAC)
    updateNSURLRequest();
#endif
}
예제 #2
0
void rfbPrintStats(rfbClientPtr cl)
{
    rfbStatList *ptr=NULL;
    char encBuf[64];
    double savings=0.0;
    int    totalRects=0;
    double totalBytes=0.0;
    double totalBytesIfRaw=0.0;

    char *name=NULL;
    int bytes=0;
    int bytesIfRaw=0;
    int count=0;

    if (cl==NULL) return;

    rfbLog("%-21.21s  %-6.6s   %9.9s/%9.9s (%6.6s)\n", "Statistics", "events", "Transmit","RawEquiv","saved");
    for (ptr = cl->statMsgList; ptr!=NULL; ptr=ptr->Next)
    {
        name       = messageNameServer2Client(ptr->type, encBuf, sizeof(encBuf));
        count      = ptr->sentCount;
        bytes      = ptr->bytesSent;
        bytesIfRaw = ptr->bytesSentIfRaw;

        savings = 0.0;
        if (bytesIfRaw>0.0)
            savings = 100.0 - (((double)bytes / (double)bytesIfRaw) * 100.0);
        if ((bytes>0) || (count>0) || (bytesIfRaw>0))
            rfbLog(" %-20.20s: %6d | %9d/%9d (%5.1f%%)\n",
                   name, count, bytes, bytesIfRaw, savings);
        totalRects += count;
        totalBytes += bytes;
        totalBytesIfRaw += bytesIfRaw;
    }

    for (ptr = cl->statEncList; ptr!=NULL; ptr=ptr->Next)
    {
        name       = encodingName(ptr->type, encBuf, sizeof(encBuf));
        count      = ptr->sentCount;
        bytes      = ptr->bytesSent;
        bytesIfRaw = ptr->bytesSentIfRaw;
        savings    = 0.0;

        if (bytesIfRaw>0.0)
            savings = 100.0 - (((double)bytes / (double)bytesIfRaw) * 100.0);
        if ((bytes>0) || (count>0) || (bytesIfRaw>0))
            rfbLog(" %-20.20s: %6d | %9d/%9d (%5.1f%%)\n",
                   name, count, bytes, bytesIfRaw, savings);
        totalRects += count;
        totalBytes += bytes;
        totalBytesIfRaw += bytesIfRaw;
    }
    savings=0.0;
    if (totalBytesIfRaw>0.0)
        savings = 100.0 - ((totalBytes/totalBytesIfRaw)*100.0);
    rfbLog(" %-20.20s: %6d | %9.0f/%9.0f (%5.1f%%)\n",
           "TOTALS", totalRects, totalBytes,totalBytesIfRaw, savings);

    totalRects=0.0;
    totalBytes=0.0;
    totalBytesIfRaw=0.0;

    rfbLog("%-21.21s  %-6.6s   %9.9s/%9.9s (%6.6s)\n", "Statistics", "events", "Received","RawEquiv","saved");
    for (ptr = cl->statMsgList; ptr!=NULL; ptr=ptr->Next)
    {
        name       = messageNameClient2Server(ptr->type, encBuf, sizeof(encBuf));
        count      = ptr->rcvdCount;
        bytes      = ptr->bytesRcvd;
        bytesIfRaw = ptr->bytesRcvdIfRaw;
        savings    = 0.0;

        if (bytesIfRaw>0.0)
            savings = 100.0 - (((double)bytes / (double)bytesIfRaw) * 100.0);
        if ((bytes>0) || (count>0) || (bytesIfRaw>0))
            rfbLog(" %-20.20s: %6d | %9d/%9d (%5.1f%%)\n",
                   name, count, bytes, bytesIfRaw, savings);
        totalRects += count;
        totalBytes += bytes;
        totalBytesIfRaw += bytesIfRaw;
    }
    for (ptr = cl->statEncList; ptr!=NULL; ptr=ptr->Next)
    {
        name       = encodingName(ptr->type, encBuf, sizeof(encBuf));
        count      = ptr->rcvdCount;
        bytes      = ptr->bytesRcvd;
        bytesIfRaw = ptr->bytesRcvdIfRaw;
        savings    = 0.0;

        if (bytesIfRaw>0.0)
            savings = 100.0 - (((double)bytes / (double)bytesIfRaw) * 100.0);
        if ((bytes>0) || (count>0) || (bytesIfRaw>0))
            rfbLog(" %-20.20s: %6d | %9d/%9d (%5.1f%%)\n",
                   name, count, bytes, bytesIfRaw, savings);
        totalRects += count;
        totalBytes += bytes;
        totalBytesIfRaw += bytesIfRaw;
    }
    savings=0.0;
    if (totalBytesIfRaw>0.0)
        savings = 100.0 - ((totalBytes/totalBytesIfRaw)*100.0);
    rfbLog(" %-20.20s: %6d | %9.0f/%9.0f (%5.1f%%)\n",
           "TOTALS", totalRects, totalBytes,totalBytesIfRaw, savings);

}
예제 #3
0
	/// \brief Get the encoding of this string as string
	/// \return the name of the encoding
	const char* encodingName() const	{return encodingName((Encoding)m_encoding, m_codepage);}