예제 #1
0
ANSC_HANDLE
HttpBmoCreateMessageBody
    (
        ANSC_HANDLE                 hThisObject
    )
{
    ANSC_STATUS                     returnStatus             = ANSC_STATUS_SUCCESS;
    PHTTP_BASIC_MESSAGE_OBJECT      pMyObject                = (PHTTP_BASIC_MESSAGE_OBJECT)hThisObject;
    PHTTP_HFP_INTERFACE             pHfpIf                   = (PHTTP_HFP_INTERFACE       )pMyObject->hHfpIf;
    PHTTP_MESSAGE_BODY_OBJECT       pMessageBody             = NULL;
    PHTTP_HFO_TRANSFER_ENCODING     pHttpHfoTransferEncoding = NULL;
    ULONG                           ulIndex                  = 0;
    ULONG                           ulEncodingType           = IANA_TCODING_CODE_IDENTITY;

    pHttpHfoTransferEncoding =
        (PHTTP_HFO_TRANSFER_ENCODING)pMyObject->GetHeaderField
            (
                (ANSC_HANDLE)pMyObject,
                HTTP_HEADER_ID_TRANSFER_ENCODING
            );

    if ( pHttpHfoTransferEncoding && (pHttpHfoTransferEncoding->EncodingCount > 0) )
    {
        ulIndex        = pHttpHfoTransferEncoding->EncodingCount - 1;
        ulEncodingType = pHttpHfoTransferEncoding->EncodingArray[ulIndex].Type;
    }

    switch ( ulEncodingType )
    {
        case    IANA_TCODING_CODE_IDENTITY :

                pMessageBody =
                    (PHTTP_MESSAGE_BODY_OBJECT)HttpCreateMboIdentity
                        (
                            pMyObject->hContainerContext,
                            (ANSC_HANDLE)pMyObject,
                            (ANSC_HANDLE)NULL
                        );

                break;

        case    IANA_TCODING_CODE_CHUNKED :

                pMessageBody =
                    (PHTTP_MESSAGE_BODY_OBJECT)HttpCreateMboChunked
                        (
                            pMyObject->hContainerContext,
                            (ANSC_HANDLE)pMyObject,
                            (ANSC_HANDLE)NULL
                        );

                break;

        default :

                break;
    }

    return  (ANSC_HANDLE)pMessageBody;
}
예제 #2
0
ULONG
HttpBmoBccPredictBodySize
    (
        ANSC_HANDLE                 hThisObject
    )
{
    ANSC_STATUS                     returnStatus = ANSC_STATUS_SUCCESS;
    PHTTP_BASIC_MESSAGE_OBJECT      pMyObject    = (PHTTP_BASIC_MESSAGE_OBJECT)hThisObject;
    PHTTP_HFP_INTERFACE             pHfpIf       = (PHTTP_HFP_INTERFACE       )pMyObject->hHfpIf;

    return  pMyObject->PredictBodySize((ANSC_HANDLE)pMyObject);
}
예제 #3
0
ANSC_HANDLE
HttpBmoBccGetHeaderField
    (
        ANSC_HANDLE                 hThisObject,
        ULONG                       ulHeaderId
    )
{
    ANSC_STATUS                     returnStatus = ANSC_STATUS_SUCCESS;
    PHTTP_BASIC_MESSAGE_OBJECT      pMyObject    = (PHTTP_BASIC_MESSAGE_OBJECT)hThisObject;
    PHTTP_HFP_INTERFACE             pHfpIf       = (PHTTP_HFP_INTERFACE       )pMyObject->hHfpIf;

    return  pMyObject->GetHeaderField((ANSC_HANDLE)pMyObject, ulHeaderId);
}
예제 #4
0
ANSC_STATUS
HttpBmoBccAddHeaderField
    (
        ANSC_HANDLE                 hThisObject,
        ANSC_HANDLE                 hHfo
    )
{
    ANSC_STATUS                     returnStatus = ANSC_STATUS_SUCCESS;
    PHTTP_BASIC_MESSAGE_OBJECT      pMyObject    = (PHTTP_BASIC_MESSAGE_OBJECT)hThisObject;
    PHTTP_HFP_INTERFACE             pHfpIf       = (PHTTP_HFP_INTERFACE       )pMyObject->hHfpIf;

    return  pMyObject->AddHeaderField((ANSC_HANDLE)pMyObject, hHfo);
}
ANSC_STATUS
HttpBmoDelHeaderField
    (
        ANSC_HANDLE                 hThisObject,
        ULONG                       ulHeaderId
    )
{
    ANSC_STATUS                     returnStatus = ANSC_STATUS_SUCCESS;
    PHTTP_BASIC_MESSAGE_OBJECT      pMyObject    = (PHTTP_BASIC_MESSAGE_OBJECT)hThisObject;
    PHTTP_HFP_INTERFACE             pHfpIf       = (PHTTP_HFP_INTERFACE       )pMyObject->hHfpIf;
    PHTTP_HEADER_FIELD              pHttpHfo     = NULL;
    ULONG                           ulHashIndex  = AnscHashUlong(ulHeaderId, HTTP_BMO_HFO_TABLE_SIZE);
    ULONG                           ulIndex      = 0;

    while ( TRUE )
    {
        pHttpHfo =
            (PHTTP_HEADER_FIELD)pMyObject->GetHeaderField2
                (
                    (ANSC_HANDLE)pMyObject,
                    ulHeaderId,
                    ulIndex
                );

        if ( !pHttpHfo )
        {
            if ( ulIndex == 0 )
            {
                return  ANSC_STATUS_CANT_FIND;
            }
            else
            {
                return ANSC_STATUS_SUCCESS;
            }
        }

        AnscAcquireLock        (&pMyObject->HfoTableLock);
        AnscQueuePopEntryByLink(&pMyObject->HfoTable[ulHashIndex], &pHttpHfo->Linkage);
        AnscReleaseLock        (&pMyObject->HfoTableLock);

        AnscFreeMemory(pHttpHfo);

        ulIndex ++;
    }

    return  ANSC_STATUS_SUCCESS;
}
예제 #6
0
ANSC_STATUS
HttpBmoSaveAsBody
    (
        ANSC_HANDLE                 hThisObject,
        PVOID                       buffer,
        ULONG                       ulSize
    )
{
    ANSC_STATUS                     returnStatus = ANSC_STATUS_SUCCESS;
    PHTTP_BASIC_MESSAGE_OBJECT      pMyObject    = (PHTTP_BASIC_MESSAGE_OBJECT)hThisObject;
    PHTTP_HFP_INTERFACE             pHfpIf       = (PHTTP_HFP_INTERFACE       )pMyObject->hHfpIf;
    PHTTP_TMH_INTERFACE             pTmhIf       = (PHTTP_TMH_INTERFACE       )pMyObject->hTmhIf;
    PHTTP_BCC_INTERFACE             pBccIf       = (PHTTP_BCC_INTERFACE       )pMyObject->hBccIf;
    PHTTP_MESSAGE_BODY_OBJECT       pMessageBody = (PHTTP_MESSAGE_BODY_OBJECT )pMyObject->hMessageBody;

    if ( !pMessageBody )
    {
        pMessageBody = (PHTTP_MESSAGE_BODY_OBJECT)pMyObject->CreateMessageBody((ANSC_HANDLE)pMyObject);

        if ( !pMessageBody )
        {
            return  ANSC_STATUS_RESOURCES;
        }
        else
        {
            pMyObject->hMessageBody = (ANSC_HANDLE)pMessageBody;

            pMessageBody->SetMode ((ANSC_HANDLE)pMessageBody, pMyObject->MboMode );
            pMessageBody->SetHfpIf((ANSC_HANDLE)pMessageBody, (ANSC_HANDLE)pHfpIf);
            pMessageBody->SetBccIf((ANSC_HANDLE)pMessageBody, (ANSC_HANDLE)pBccIf);
        }
    }

    if ( pMessageBody )
    {
        returnStatus =
            pMessageBody->SaveAsBody
                (
                    (ANSC_HANDLE)pMessageBody,
                    buffer,
                    ulSize
                );
    }

    return  returnStatus;
}
char*
HttpBmoGetHeaderValueById2
    (
        ANSC_HANDLE                 hThisObject,
        ULONG                       ulHeaderId,
        ULONG                       ulIndex
    )
{
    ANSC_STATUS                     returnStatus = ANSC_STATUS_SUCCESS;
    PHTTP_BASIC_MESSAGE_OBJECT      pMyObject    = (PHTTP_BASIC_MESSAGE_OBJECT   )hThisObject;
    PHTTP_HFP_INTERFACE             pHfpIf       = (PHTTP_HFP_INTERFACE          )pMyObject->hHfpIf;
#ifndef _CCSP_CWMP_TCP_CONNREQ_HANDLER
    PHTTP_HELPER_CONTAINER_OBJECT   pHttpHco     = (PHTTP_HELPER_CONTAINER_OBJECT)pMyObject->hContainerContext;
#endif
    PHTTP_HEADER_FIELD              pHttpHfo     = NULL;
    char*                           pHttpHfValue = NULL;

    pHttpHfo =
        (PHTTP_HEADER_FIELD)pMyObject->GetHeaderField2
            (
                (ANSC_HANDLE)pMyObject,
                ulHeaderId,
                ulIndex
            );

    if ( !pHttpHfo )
    {
        return  NULL;
    }
    else if ( !(pHttpHfo->Flags & HTTP_FIELD_FLAG_LINE_PRESENT) )
    {
        returnStatus =
            pHfpIf->BuildHeader
                (
                    pHfpIf->hOwnerContext,
                    (ANSC_HANDLE)pHttpHfo,
                    NULL,
                    0
                );
    }

    AnscHttpGetHfValue(pHttpHfo->HeaderLine, AnscSizeOfString(pHttpHfo->HeaderLine), pHttpHfValue);

    return  pHttpHfValue;
}
예제 #8
0
ANSC_STATUS
HttpBmoAppendBodyBdo
    (
        ANSC_HANDLE                 hThisObject,
        ANSC_HANDLE                 hBdo
    )
{
    ANSC_STATUS                     returnStatus = ANSC_STATUS_SUCCESS;
    PHTTP_BASIC_MESSAGE_OBJECT      pMyObject    = (PHTTP_BASIC_MESSAGE_OBJECT)hThisObject;
    PHTTP_HFP_INTERFACE             pHfpIf       = (PHTTP_HFP_INTERFACE       )pMyObject->hHfpIf;
    PHTTP_TMH_INTERFACE             pTmhIf       = (PHTTP_TMH_INTERFACE       )pMyObject->hTmhIf;
    PHTTP_BCC_INTERFACE             pBccIf       = (PHTTP_BCC_INTERFACE       )pMyObject->hBccIf;
    PHTTP_MESSAGE_BODY_OBJECT       pMessageBody = (PHTTP_MESSAGE_BODY_OBJECT )pMyObject->hMessageBody;
    PANSC_BUFFER_DESCRIPTOR         pBodyBdo     = (PANSC_BUFFER_DESCRIPTOR   )hBdo;

    if ( !pMessageBody )
    {
        pMessageBody = (PHTTP_MESSAGE_BODY_OBJECT)pMyObject->CreateMessageBody((ANSC_HANDLE)pMyObject);

        if ( !pMessageBody )
        {
            return  ANSC_STATUS_RESOURCES;
        }
        else
        {
            pMyObject->hMessageBody = (ANSC_HANDLE)pMessageBody;

            pMessageBody->SetMode ((ANSC_HANDLE)pMessageBody, pMyObject->MboMode );
            pMessageBody->SetHfpIf((ANSC_HANDLE)pMessageBody, (ANSC_HANDLE)pHfpIf);
            pMessageBody->SetBccIf((ANSC_HANDLE)pMessageBody, (ANSC_HANDLE)pBccIf);
        }
    }

    if ( pMessageBody )
    {
        returnStatus =
            pMessageBody->AppendBodyBdo
                (
                    (ANSC_HANDLE)pMessageBody,
                    (ANSC_HANDLE)pBodyBdo
                );
    }

    return  returnStatus;
}
ANSC_STATUS
HttpBmoSetHeaderValueById
    (
        ANSC_HANDLE                 hThisObject,
        ULONG                       ulHeaderId,
        char*                       value
    )
{
    ANSC_STATUS                     returnStatus = ANSC_STATUS_SUCCESS;
    PHTTP_BASIC_MESSAGE_OBJECT      pMyObject    = (PHTTP_BASIC_MESSAGE_OBJECT   )hThisObject;
    PHTTP_HFP_INTERFACE             pHfpIf       = (PHTTP_HFP_INTERFACE          )pMyObject->hHfpIf;
    PHTTP_HELPER_CONTAINER_OBJECT   pHttpHco     = (PHTTP_HELPER_CONTAINER_OBJECT)pMyObject->hContainerContext;
    PHTTP_HEADER_FIELD              pHttpHfo     = NULL;
    char*                           pHeaderName  = NULL;

    pHeaderName =
        pHttpHco->GetHeaderName
            (
                (ANSC_HANDLE)pHttpHco,
                ulHeaderId
            );

    if ( !pHeaderName )
    {
        return  ANSC_STATUS_UNAPPLICABLE;
    }
    else
    {
        returnStatus =
            pMyObject->SetHeaderValueByName
                (
                    (ANSC_HANDLE)pMyObject,
                    pHeaderName,
                    value
                );
    }

    return  returnStatus;
}
ANSC_STATUS
HttpBmoClearHeaders
    (
        ANSC_HANDLE                 hThisObject
    )
{
    ANSC_STATUS                     returnStatus = ANSC_STATUS_SUCCESS;
    PHTTP_BASIC_MESSAGE_OBJECT      pMyObject    = (PHTTP_BASIC_MESSAGE_OBJECT)hThisObject;
    PHTTP_HFP_INTERFACE             pHfpIf       = (PHTTP_HFP_INTERFACE       )pMyObject->hHfpIf;
    PANSC_BUFFER_DESCRIPTOR         pHeaderBdo   = (PANSC_BUFFER_DESCRIPTOR   )pMyObject->hHeaderBdo;

    if ( pHeaderBdo )
    {
        AnscFreeBdo((ANSC_HANDLE)pHeaderBdo);

        pMyObject->hHeaderBdo = (ANSC_HANDLE)NULL;
    }

    pMyObject->DelStartLine((ANSC_HANDLE)pMyObject);
    pMyObject->DelAllHfos  ((ANSC_HANDLE)pMyObject);

    return  ANSC_STATUS_SUCCESS;
}
예제 #11
0
ANSC_STATUS
HttpBmoSaveAsMbo
    (
        ANSC_HANDLE                 hThisObject,
        ANSC_HANDLE                 hMbo
    )
{
    ANSC_STATUS                     returnStatus = ANSC_STATUS_SUCCESS;
    PHTTP_BASIC_MESSAGE_OBJECT      pMyObject    = (PHTTP_BASIC_MESSAGE_OBJECT)hThisObject;
    PHTTP_HFP_INTERFACE             pHfpIf       = (PHTTP_HFP_INTERFACE       )pMyObject->hHfpIf;
    PHTTP_TMH_INTERFACE             pTmhIf       = (PHTTP_TMH_INTERFACE       )pMyObject->hTmhIf;
    PHTTP_BCC_INTERFACE             pBccIf       = (PHTTP_BCC_INTERFACE       )pMyObject->hBccIf;
    PHTTP_MESSAGE_BODY_OBJECT       pMessageBody = (PHTTP_MESSAGE_BODY_OBJECT )hMbo;

    pMyObject->ClearBody((ANSC_HANDLE)pMyObject);

    pMyObject->hMessageBody = (ANSC_HANDLE)pMessageBody;

    pMessageBody->SetMode ((ANSC_HANDLE)pMessageBody, pMyObject->MboMode );
    pMessageBody->SetHfpIf((ANSC_HANDLE)pMessageBody, (ANSC_HANDLE)pHfpIf);
    pMessageBody->SetBccIf((ANSC_HANDLE)pMessageBody, (ANSC_HANDLE)pBccIf);

    return  returnStatus;
}
ANSC_STATUS
HttpBmoParseHeaders
    (
        ANSC_HANDLE                 hThisObject
    )
{
    ANSC_STATUS                     returnStatus  = ANSC_STATUS_SUCCESS;
    PHTTP_BASIC_MESSAGE_OBJECT      pMyObject     = (PHTTP_BASIC_MESSAGE_OBJECT)hThisObject;
    PHTTP_HFP_INTERFACE             pHfpIf        = (PHTTP_HFP_INTERFACE       )pMyObject->hHfpIf;
    PANSC_BUFFER_DESCRIPTOR         pHeaderBdo    = (PANSC_BUFFER_DESCRIPTOR   )pMyObject->hHeaderBdo;
    PHTTP_HEADER_FIELD              pHttpHfo      = NULL;
    PVOID                           pHeaderBuffer = NULL;
    ULONG                           ulBufferSize  = 0;
    char*                           pHfStart      = NULL;
    ULONG                           ulSkipSize    = 0;
    char*                           pRawHfLine    = NULL;
    char*                           pStdHfLine    = (char*)pMyObject->ScratchPad1;
    ULONG                           ulRawLineSize = 0;
    ULONG                           ulStdLineSize = 0;

    pMyObject->DelStartLine((ANSC_HANDLE)pMyObject);
    pMyObject->DelAllHfos  ((ANSC_HANDLE)pMyObject);

    returnStatus = pMyObject->ParseStartLine((ANSC_HANDLE)pMyObject);

    if ( returnStatus != ANSC_STATUS_SUCCESS )
    {
        return  returnStatus;
    }
    else if ( !pHeaderBdo )
    {
        return  ANSC_STATUS_UNAPPLICABLE;
    }
    else
    {
        pHeaderBuffer = AnscBdoGetBlock    (pHeaderBdo);
        ulBufferSize  = AnscBdoGetBlockSize(pHeaderBdo);
    }

    AnscHttpFindHfStart(pHeaderBuffer, ulBufferSize, pHfStart);

    if ( !pHfStart )
    {
        return  ANSC_STATUS_UNAPPLICABLE;
    }
    else
    {
        ulSkipSize    = (ULONG)pHfStart - (ULONG)pHeaderBuffer;
        ulBufferSize -= ulSkipSize;
        pRawHfLine    = pHfStart;
    }

    /*
     * Skip the first line, which is the start line: request-line in client message and status-line
     * in server message.
     */
    AnscHttpGetHfLineSize(pRawHfLine, ulBufferSize, ulRawLineSize);

    pRawHfLine   += ulRawLineSize;
    ulBufferSize -= ulRawLineSize;

    /*
     * We don't have to verify the completeness of the header fields, since the caller SHOULD have
     * done so already. We create a separate HTTP Header Field Object for each header line and add
     * it into the distributed hash table. The end of header fields is signalled by the presece of
     * a CRLF pair.
     */
    while ( (ulBufferSize > 0) && pRawHfLine && !AnscHttpIsCr(*pRawHfLine) && !AnscHttpIsLf(*pRawHfLine) )
    {
        AnscHttpGetHfLineSize(pRawHfLine, ulBufferSize, ulRawLineSize);

        if ( ulRawLineSize <= pMyObject->PadSize1 )
        {
            AnscHttpPrepareHeader(pRawHfLine, ulRawLineSize, pStdHfLine, ulStdLineSize);

            pStdHfLine[ulStdLineSize + 0] = HTTP_CARRIAGE_RETURN;
            pStdHfLine[ulStdLineSize + 1] = HTTP_LINE_FEED;

            pHttpHfo =
                (PHTTP_HEADER_FIELD)pHfpIf->ParseHeader
                    (
                        pHfpIf->hOwnerContext,
                        pStdHfLine,
                        ulStdLineSize
                    );

            if ( pHttpHfo )
            {
                returnStatus =
                    pMyObject->AddHeaderField
                        (
                            (ANSC_HANDLE)pMyObject,
                            (ANSC_HANDLE)pHttpHfo
                        );
            }
        }

        pRawHfLine   += ulRawLineSize;
        ulBufferSize -= ulRawLineSize;
    }

    return  ANSC_STATUS_SUCCESS;
}
ANSC_STATUS
HttpBmoSetHeaderValueByName
    (
        ANSC_HANDLE                 hThisObject,
        char*                       name,
        char*                       value
    )
{
    ANSC_STATUS                     returnStatus = ANSC_STATUS_SUCCESS;
    PHTTP_BASIC_MESSAGE_OBJECT      pMyObject    = (PHTTP_BASIC_MESSAGE_OBJECT   )hThisObject;
    PHTTP_HFP_INTERFACE             pHfpIf       = (PHTTP_HFP_INTERFACE          )pMyObject->hHfpIf;
#ifndef _CCSP_CWMP_TCP_CONNREQ_HANDLER
    PHTTP_HELPER_CONTAINER_OBJECT   pHttpHco     = (PHTTP_HELPER_CONTAINER_OBJECT)pMyObject->hContainerContext;
#endif
    PHTTP_HEADER_FIELD              pHttpHfo     = NULL;
    char*                           pHttpHfValue = NULL;
    char*                           pHfLine      = (char*)pMyObject->ScratchPad1;
    ULONG                           ulLineSize   = 0;

    if ( (AnscSizeOfString(name) + AnscSizeOfString(value) + 4) >= pMyObject->PadSize1 )
    {
        return  ANSC_STATUS_RESOURCES;
    }
    else
    {
        AnscCopyString(pHfLine, name);

        ulLineSize  = AnscSizeOfString(name);
        pHfLine[ulLineSize + 0] = HTTP_COLON;
        pHfLine[ulLineSize + 1] = HTTP_SPACE;
        ulLineSize += 2;

        AnscCopyString(pHfLine + ulLineSize, value);

        ulLineSize += AnscSizeOfString(value);
        pHfLine[ulLineSize + 0] = HTTP_CARRIAGE_RETURN;
        pHfLine[ulLineSize + 1] = HTTP_LINE_FEED;
    }

    pHttpHfo =
        (PHTTP_HEADER_FIELD)pHfpIf->ParseHeader
            (
                pHfpIf->hOwnerContext,
                pHfLine,
                ulLineSize
            );

    if ( !pHttpHfo )
    {
        return  ANSC_STATUS_UNAPPLICABLE;
    }
    else
    {
        returnStatus =
            pMyObject->AddHeaderField
                (
                    (ANSC_HANDLE)pMyObject,
                    (ANSC_HANDLE)pHttpHfo
                );
    }

    return  returnStatus;
}
char*
HttpBmoGetHeaderValueByName2
    (
        ANSC_HANDLE                 hThisObject,
        char*                       name,
        ULONG                       ulIndex
    )
{
    ANSC_STATUS                     returnStatus = ANSC_STATUS_SUCCESS;
    PHTTP_BASIC_MESSAGE_OBJECT      pMyObject    = (PHTTP_BASIC_MESSAGE_OBJECT   )hThisObject;
    PHTTP_HFP_INTERFACE             pHfpIf       = (PHTTP_HFP_INTERFACE          )pMyObject->hHfpIf;
#ifndef _CCSP_CWMP_TCP_CONNREQ_HANDLER
    PHTTP_HELPER_CONTAINER_OBJECT   pHttpHco     = (PHTTP_HELPER_CONTAINER_OBJECT)pMyObject->hContainerContext;
#endif
    PHTTP_HEADER_FIELD              pHttpHfo     = NULL;
    char*                           pHttpHfValue = NULL;
    char*                           pHttpHfColon = NULL;
    PSINGLE_LINK_ENTRY              pSLinkEntry  = NULL;
    ULONG                           ulHeaderId   = HTTP_HEADER_ID_RESERVED;
    ULONG                           i            = 0;
    ULONG                           ulCount      = 0;

    ulHeaderId =
#ifdef _CCSP_CWMP_TCP_CONNREQ_HANDLER
        AnscHttpGetHeaderCode(name);
#else
        pHttpHco->GetHeaderId
            (
                (ANSC_HANDLE)pHttpHco,
                name
            );
#endif

    if ( ulHeaderId != HTTP_HEADER_ID_RESERVED )
    {
        return  pMyObject->GetHeaderValueById2((ANSC_HANDLE)pMyObject, ulHeaderId, ulIndex);
    }

    AnscAcquireLock(&pMyObject->HfoTableLock);

    for ( i = 0; i < HTTP_BMO_HFO_TABLE_SIZE; i++ )
    {
        pSLinkEntry = AnscQueueGetFirstEntry(&pMyObject->HfoTable[i]);

        while ( pSLinkEntry )
        {
            pHttpHfo    = ACCESS_HTTP_HEADER_FIELD(pSLinkEntry);
            pSLinkEntry = AnscQueueGetNextEntry(pSLinkEntry);

            if ( !(pHttpHfo->Flags & HTTP_FIELD_FLAG_LINE_PRESENT) )
            {
                continue;
            }
            else if ( AnscSizeOfString(pHttpHfo->HeaderLine) < AnscSizeOfString(name) )
            {
                continue;
            }
            else
            {
                pHttpHfColon = _ansc_strchr(pHttpHfo->HeaderLine, ':');
            }

            if ( !pHttpHfColon )
            {
                continue;
            }
            else if ( ((ULONG)pHttpHfColon - (ULONG)pHttpHfo->HeaderLine) != AnscSizeOfString(name) )
            {
                continue;
            }
            else if ( AnscEqualString2
                        (
                            pHttpHfo->HeaderLine,
                            name,
                            AnscSizeOfString(name),
                            FALSE
                        ) )
            {
                if ( ulCount != ulIndex )
                {
                    ulCount ++;
                    continue;
                }

                AnscReleaseLock(&pMyObject->HfoTableLock);

                AnscHttpGetHfValue(pHttpHfo->HeaderLine, AnscSizeOfString(pHttpHfo->HeaderLine), pHttpHfValue);

                return  pHttpHfValue;
            }
        }
    }

    AnscReleaseLock(&pMyObject->HfoTableLock);

    return  NULL;
}
ANSC_STATUS
HttpBmoCopyHeadersFrom
    (
        ANSC_HANDLE                 hThisObject,
        PVOID                       buffer,
        PULONG                      pulSize
    )
{
    ANSC_STATUS                     returnStatus  = ANSC_STATUS_SUCCESS;
    PHTTP_BASIC_MESSAGE_OBJECT      pMyObject     = (PHTTP_BASIC_MESSAGE_OBJECT)hThisObject;
    PHTTP_HFP_INTERFACE             pHfpIf        = (PHTTP_HFP_INTERFACE       )pMyObject->hHfpIf;
    PANSC_BUFFER_DESCRIPTOR         pHeaderBdo    = (PANSC_BUFFER_DESCRIPTOR   )pMyObject->hHeaderBdo;
    PHTTP_HEADER_FIELD              pHttpHfo      = NULL;
    PSINGLE_LINK_ENTRY              pSLinkEntry   = NULL;
    ULONG                           ulHeadersSize = 0;
    ULONG                           ulCopySize    = 0;
    ULONG                           ulLeftSize    = *pulSize;
    char*                           pHfStream     = (char*)buffer;
    ULONG                           i             = 0;

    if ( *pulSize < pMyObject->GetHeadersSize((ANSC_HANDLE)pMyObject) )
    {
        return  ANSC_STATUS_BAD_SIZE;
    }
    else if ( pHeaderBdo )
    {
        AnscCopyMemory
            (
                buffer,
                AnscBdoGetBlock    (pHeaderBdo),
                AnscBdoGetBlockSize(pHeaderBdo)
            );

        *pulSize = AnscBdoGetBlockSize(pHeaderBdo);

        return  ANSC_STATUS_SUCCESS;
    }

    ulCopySize   = ulLeftSize;
    pHfStream    = (char*)((ULONG)buffer + ulHeadersSize);
    returnStatus =
        pMyObject->CopyStartLineFrom
            (
                (ANSC_HANDLE)pMyObject,
                (PVOID)pHfStream,
                &ulCopySize
            );

    if ( returnStatus != ANSC_STATUS_SUCCESS )
    {
        return  returnStatus;
    }
    else
    {
        pHfStream     += ulCopySize;
        ulHeadersSize += ulCopySize;
        ulLeftSize    -= ulCopySize;

        pHfStream[0] = HTTP_CARRIAGE_RETURN;
        pHfStream[1] = HTTP_LINE_FEED;

        pHfStream     += 2;
        ulHeadersSize += 2;
        ulLeftSize    -= 2;
    }

    AnscAcquireLock(&pMyObject->HfoTableLock);

    for ( i = 0; i < HTTP_BMO_HFO_TABLE_SIZE; i++ )
    {
        pSLinkEntry = AnscQueueGetFirstEntry(&pMyObject->HfoTable[i]);

        while ( pSLinkEntry )
        {
            pHttpHfo    = ACCESS_HTTP_HEADER_FIELD(pSLinkEntry);
            pSLinkEntry = AnscQueueGetNextEntry(pSLinkEntry);

            ulCopySize  = pHfpIf->GetHeaderSize(pHfpIf->hOwnerContext, (ANSC_HANDLE)pHttpHfo);

            if ( ulCopySize > 0 )
            {
                returnStatus =
                    pHfpIf->BuildHeader
                        (
                            pHfpIf->hOwnerContext,
                            (ANSC_HANDLE)pHttpHfo,
                            (PVOID)pHfStream,
                            ulCopySize
                        );

                if ( returnStatus != ANSC_STATUS_SUCCESS )
                {
                    return  returnStatus;
                }
                else
                {
                    pHfStream     += ulCopySize;
                    ulHeadersSize += ulCopySize;
                    ulLeftSize    -= ulCopySize;

                    pHfStream[0] = HTTP_CARRIAGE_RETURN;
                    pHfStream[1] = HTTP_LINE_FEED;

                    pHfStream     += 2;
                    ulHeadersSize += 2;
                    ulLeftSize    -= 2;
                }
            }
        }
    }

    AnscReleaseLock(&pMyObject->HfoTableLock);

    pHfStream[0] = HTTP_CARRIAGE_RETURN;
    pHfStream[1] = HTTP_LINE_FEED;

    pHfStream     += 2;
    ulHeadersSize += 2;
    ulLeftSize    -= 2;

    *pulSize = ulHeadersSize;

    return  ANSC_STATUS_SUCCESS;
}
예제 #16
0
ANSC_STATUS
HttpBmoAppendBody
    (
        ANSC_HANDLE                 hThisObject,
        PVOID                       buffer,
        ULONG                       ulSize
    )
{
    ANSC_STATUS                     returnStatus = ANSC_STATUS_SUCCESS;
    PHTTP_BASIC_MESSAGE_OBJECT      pMyObject    = (PHTTP_BASIC_MESSAGE_OBJECT)hThisObject;
    PHTTP_HFP_INTERFACE             pHfpIf       = (PHTTP_HFP_INTERFACE       )pMyObject->hHfpIf;
    PHTTP_TMH_INTERFACE             pTmhIf       = (PHTTP_TMH_INTERFACE       )pMyObject->hTmhIf;
    PHTTP_BCC_INTERFACE             pBccIf       = (PHTTP_BCC_INTERFACE       )pMyObject->hBccIf;
    PHTTP_MESSAGE_BODY_OBJECT       pMessageBody = (PHTTP_MESSAGE_BODY_OBJECT )pMyObject->hMessageBody;
    PANSC_BUFFER_DESCRIPTOR         pBodyBdo     = (PANSC_BUFFER_DESCRIPTOR   )NULL;

    if ( !pMessageBody )
    {
        pMessageBody = (PHTTP_MESSAGE_BODY_OBJECT)pMyObject->CreateMessageBody((ANSC_HANDLE)pMyObject);

        if ( !pMessageBody )
        {
            return  ANSC_STATUS_RESOURCES;
        }
        else
        {
            pMyObject->hMessageBody = (ANSC_HANDLE)pMessageBody;

            pMessageBody->SetMode ((ANSC_HANDLE)pMessageBody, pMyObject->MboMode );
            pMessageBody->SetHfpIf((ANSC_HANDLE)pMessageBody, (ANSC_HANDLE)pHfpIf);
            pMessageBody->SetBccIf((ANSC_HANDLE)pMessageBody, (ANSC_HANDLE)pBccIf);
        }
    }

    if ( TRUE )
    {
        pBodyBdo =
            (PANSC_BUFFER_DESCRIPTOR)AnscAllocateBdo
                (
                    ulSize,
                    0,
                    ulSize
                );

        if ( !pBodyBdo )
        {
            return  ANSC_STATUS_RESOURCES;
        }
        else
        {
            AnscCopyMemory
                (
                    AnscBdoGetBlock(pBodyBdo),
                    buffer,
                    ulSize
                );
        }
    }

    if ( pMessageBody )
    {
        returnStatus =
            pMessageBody->AppendBodyBdo
                (
                    (ANSC_HANDLE)pMessageBody,
                    (ANSC_HANDLE)pBodyBdo
                );
    }

    return  returnStatus;
}