Skip to main content
ATL Server Library Reference 
IHttpRequestLookup Interface 

This interface provides access to the file, form variable, and query parameter collections associated with an HTTP request.


__interface ATL_NO_VTABLE
__declspec( uuid( "A5990B44-FF74-4bfe-B66D-F9E7E9F42D42" ))
IHttpRequestLookup :
   public IUnknown

This interface is implemented by CHttpRequest.

Header: atlsiface.h

HTTP_CODE InitializeChild(
    AtlServerRequest* pRequestInfo, 
    IServiceProvider* pProvider, 
    IHttpRequestLookup* pLookup
    )
{
    _ATLTRY
    {
        // This override of InitializeChild shows how to use
        // the IHttpRequestLookup interface to obtain
        // query parameters, form variabless,
        // and files from a parent handler.

        HTTP_CODE hcErr = InitializeInternal(pRequestInfo, pProvider);
        if (!hcErr)
        {
            CComPtr<IHttpServerContext> spServerContext;
            HRESULT hr = pLookup->GetServerContext(&spServerContext);

            if (pRequestInfo->pServerContext != spServerContext)
            {
                m_HttpResponse.Initialize(pRequestInfo->pServerContext);
            }
            else
            {
                m_HttpResponse.Initialize(spServerContext);
            }

            m_HttpResponse.HaveSentHeaders(TRUE);

            // Query parameters.
            m_HttpResponse << "Query Params:<br>";
            LPCSTR szName = NULL;
            LPCSTR szValue = NULL;

            POSITION pos = pLookup->GetFirstQueryParam(&szName, &szValue);
            while (pos != NULL)
            {
                m_HttpResponse << "name : " << szName 
                             << ", value : " << szValue
                             << "<br>";
                pos = pLookup->GetNextQueryParam(pos, &szName, &szValue);
            }

            // Form variables.
            m_HttpResponse << "<hr>Form Vars:<br>";

            pos = pLookup->GetFirstFormVar(&szName, &szValue);
            while (pos != NULL)
            {
                m_HttpResponse << "name : " << szName 
                             << ", value : " << szValue 
                             << "<br>";
                pos = pLookup->GetNextFormVar(pos, &szName, &szValue);
            }

            // Files.
            m_HttpResponse << "<hr>Uploaded Files:<br>";
            IHttpFile *pFile = NULL;
            pos = pLookup->GetFirstFile(&szName, &pFile);
            while (pos != NULL)
            {
                m_HttpResponse << "name : " << szName 
                             << ", temp file : "
                             << pFile->GetTempFileName()
                             << "<br>";
                pos = pLookup->GetNextFile(pos, &szName, &pFile);
            }
        }
    }
    _ATLCATCHALL()
    {
        return HTTP_ERROR(500, ISE_SUBERR_OUTOFMEM);
    }

    m_HttpResponse.Flush(TRUE);
    return HTTP_SUCCESS_NO_PROCESS;
}