Пример #1
0
void HttpSocket::IHttpServer_Respond(const HttpResponse& res)
{
    m_res = res;

    SetHttpVersion( m_res.HttpVersion() );
    SetStatus( Utility::l2string(m_res.HttpStatusCode()) );
    SetStatusText( m_res.HttpStatusMsg() );

    if (!ResponseHeaderIsSet("content-length"))
    {
        AddResponseHeader( "content-length", Utility::l2string( m_res.GetFile().size() ) );
    }
    for (Utility::ncmap<std::string>::const_iterator it = m_res.Headers().begin(); it != m_res.Headers().end(); ++it)
    {
        AddResponseHeader( it -> first, it -> second );
    }
    std::list<std::string> vec = m_res.CookieNames();
    for (std::list<std::string>::iterator it2 = vec.begin(); it2 != vec.end(); ++it2)
    {
        AppendResponseHeader( "set-cookie", m_res.Cookie(*it2) );
    }
    SendResponse();

    OnTransferLimit();
}
Пример #2
0
void HTTPRequest::AppendContentLengthHeader(UInt32 length_32bit)
{
    char* contentLength = NEW char[256];
    qtss_sprintf(contentLength, "%lu", length_32bit);
    StrPtrLen contentLengthPtr(contentLength);
    AppendResponseHeader(httpContentLengthHeader, &contentLengthPtr);
}
Пример #3
0
void HTTPRequest::AppendContentLengthHeader(UInt64 length_64bit)
{
    char* contentLength = NEW char[256];
    qtss_sprintf(contentLength, "%"_64BITARG_"d", length_64bit);
    StrPtrLen contentLengthPtr(contentLength);
    AppendResponseHeader(httpContentLengthHeader, &contentLengthPtr);
}
Пример #4
0
void HTTPRequest::AppendContentLengthHeader(UInt32 length_32bit)
{
    //char* contentLength = NEW char[256];
	char contentLength[256] = { 0 };
    qtss_sprintf(contentLength, "%"_U32BITARG_"", length_32bit);
    StrPtrLen contentLengthPtr(contentLength);
    AppendResponseHeader(httpContentLengthHeader, &contentLengthPtr);
}
Пример #5
0
void HTTPRequest::AppendConnectionKeepAliveHeader()
{
    AppendResponseHeader(httpConnectionHeader, &sKeepAliveString);
}
Пример #6
0
void HTTPRequest::AppendConnectionCloseHeader()
{
    AppendResponseHeader(httpConnectionHeader, &sCloseString);
}