Example #1
0
//////////////////////////////////////////////////////////////////////////
// CHttpHelper
bool CHttpHelper::IsConnectionKeepAlive(NPT_HttpMessage& message) 
{
	const NPT_String* connection = 
		message.GetHeaders().GetHeaderValue(NPT_HTTP_HEADER_CONNECTION);

	// the DLNA says that all HTTP 1.0 requests should be closed immediately by the server
	NPT_String protocol = message.GetProtocol();
	if (protocol.Compare(NPT_HTTP_PROTOCOL_1_0, true) == 0) return false;

	// all HTTP 1.1 requests without a Connection header 
	// or with a keep-alive Connection header should be kept alive if possible 
	return (!connection || connection->Compare("keep-alive", true) == 0);
}
Example #2
0
/*----------------------------------------------------------------------
|   PLT_HttpHelper::IsConnectionKeepAlive
+---------------------------------------------------------------------*/
bool
PLT_HttpHelper::IsConnectionKeepAlive(NPT_HttpMessage& message) 
{
    const NPT_String* connection = 
        message.GetHeaders().GetHeaderValue(NPT_HTTP_HEADER_CONNECTION);

    // if we have the keep-alive header then no matter what protocol version, we want keep-alive
    // if we are in HTTP 1.1 and we don't have the keep-alive header, make sure we also don't have the Connection: close header.
    NPT_String protocol = message.GetProtocol();
    if ((!protocol.Compare(NPT_HTTP_PROTOCOL_1_1, true) && (!connection || connection->Compare("Close", true))) || 
        (connection && !connection->Compare("keep-alive", true))) {
        return true; 
    }

    return false;
}
/*----------------------------------------------------------------------
|   PLT_HttpHelper::IsConnectionKeepAlive
+---------------------------------------------------------------------*/
bool
PLT_HttpHelper::IsConnectionKeepAlive(NPT_HttpMessage& message) 
{
    const NPT_String* connection = 
        message.GetHeaders().GetHeaderValue(NPT_HTTP_HEADER_CONNECTION);

    // the DLNA says that all HTTP 1.0 requests should be closed immediately by the server
    // all HTTP 1.1 requests without a Connection header or with a Connection header 
    // NOT saying "Close" should be kept alive
    NPT_String protocol = message.GetProtocol();
    if (!protocol.Compare(NPT_HTTP_PROTOCOL_1_1, true) && 
        (!connection || connection->Compare("close", true))) {
        return true; 
    }

    return false;
}