コード例 #1
0
ANSC_STATUS
WebRooProcess
    (
        ANSC_HANDLE                 hThisObject,
        ANSC_HANDLE                 hBmoReq,
        ANSC_HANDLE                 hBmoRep
    )
{
    ANSC_STATUS                     returnStatus    = ANSC_STATUS_SUCCESS;
    PWEB_RESOURCE_OWNER_OBJECT      pMyObject       = (PWEB_RESOURCE_OWNER_OBJECT  )hThisObject;
    PWEB_RESOURCE_OWNER_PROPERTY    pProperty       = (PWEB_RESOURCE_OWNER_PROPERTY)&pMyObject->Property;
    PHTTP_RCP_INTERFACE             pRcpIf          = (PHTTP_RCP_INTERFACE         )pMyObject->hRcpIf;
    PHTTP_BMO_REQ_OBJECT            pBmoReq         = (PHTTP_BMO_REQ_OBJECT        )hBmoReq;
    PHTTP_BMO_REP_OBJECT            pBmoRep         = (PHTTP_BMO_REP_OBJECT        )hBmoRep;
    PHTTP_REQUEST_INFO              pReqInfo        = (PHTTP_REQUEST_INFO          )pBmoReq->GetReqInfo    ((ANSC_HANDLE)pBmoReq);
    PANSC_TOKEN_CHAIN               pPathTokenChain = (PANSC_TOKEN_CHAIN           )pBmoReq->GetRecvContext((ANSC_HANDLE)pBmoReq);
    PWEB_GENERAL_SESSION_OBJECT     pSession        = (PWEB_GENERAL_SESSION_OBJECT )pBmoRep->GetRecvContext((ANSC_HANDLE)pBmoRep);
    PWEB_AUTH_SERVER_OBJECT         pAuthServer     = (PWEB_AUTH_SERVER_OBJECT     )pMyObject->hAuthServer;
    BOOL                            bAuthenticated  = TRUE;

    pBmoReq->SetRcpIf     ((ANSC_HANDLE)pBmoReq, (ANSC_HANDLE)pRcpIf   );
    pBmoRep->SetWebServlet((ANSC_HANDLE)pBmoReq, (ANSC_HANDLE)pMyObject);

    if ( pReqInfo->MajorVersion != HTTP_CURRENT_MAJOR_VERSION )
    {
        returnStatus =
            pMyObject->ReplyReq
                (
                    (ANSC_HANDLE)pMyObject,
                    (ANSC_HANDLE)pBmoReq,
                    (ANSC_HANDLE)pBmoRep,
                    HTTP_STATUS_VERSION_NOT_SUPPORTED,
                    (ANSC_HANDLE)NULL
                );

        goto  EXIT1;
    }

    if ( pAuthServer )
    {
        returnStatus = 
            pAuthServer->AuthenticateReq
                (
                    (ANSC_HANDLE)pAuthServer,
                    (ANSC_HANDLE)pBmoReq,
                    (ANSC_HANDLE)pBmoRep
                );

        bAuthenticated  = ( returnStatus == ANSC_STATUS_SUCCESS );
        returnStatus = ANSC_STATUS_SUCCESS;
    }

    if ( bAuthenticated )
    {
        switch ( pBmoReq->GetMethod((ANSC_HANDLE)pBmoReq) )
        {
            case    HTTP_METHOD_CODE_OPTIONS :

                    returnStatus =
                        pMyObject->DoOptions
                            (
                                (ANSC_HANDLE)pMyObject,
                                (ANSC_HANDLE)pBmoReq,
                                (ANSC_HANDLE)pBmoRep
                            );

                    break;

            case    HTTP_METHOD_CODE_GET :

                    returnStatus =
                        pMyObject->DoGet
                            (
                                (ANSC_HANDLE)pMyObject,
                                (ANSC_HANDLE)pBmoReq,
                                (ANSC_HANDLE)pBmoRep
                            );

                    break;

            case    HTTP_METHOD_CODE_HEAD :

                    returnStatus =
                        pMyObject->DoHead
                            (
                                (ANSC_HANDLE)pMyObject,
                                (ANSC_HANDLE)pBmoReq,
                                (ANSC_HANDLE)pBmoRep
                            );

                    break;

            case    HTTP_METHOD_CODE_POST :

                    returnStatus =
                        pMyObject->DoPost
                            (
                                (ANSC_HANDLE)pMyObject,
                                (ANSC_HANDLE)pBmoReq,
                                (ANSC_HANDLE)pBmoRep
                            );

                    break;

            case    HTTP_METHOD_CODE_PUT :

                    returnStatus =
                        pMyObject->DoPut
                            (
                                (ANSC_HANDLE)pMyObject,
                                (ANSC_HANDLE)pBmoReq,
                                (ANSC_HANDLE)pBmoRep
                            );

                    break;

            case    HTTP_METHOD_CODE_DELETE :

                    returnStatus =
                        pMyObject->DoDelete
                            (
                                (ANSC_HANDLE)pMyObject,
                                (ANSC_HANDLE)pBmoReq,
                                (ANSC_HANDLE)pBmoRep
                            );

                    break;

            case    HTTP_METHOD_CODE_TRACE :

                    returnStatus =
                        pMyObject->DoTrace
                            (
                                (ANSC_HANDLE)pMyObject,
                                (ANSC_HANDLE)pBmoReq,
                                (ANSC_HANDLE)pBmoRep
                            );

                    break;

            case    HTTP_METHOD_CODE_CONNECT :

                    returnStatus =
                        pMyObject->DoConnect
                            (
                                (ANSC_HANDLE)pMyObject,
                                (ANSC_HANDLE)pBmoReq,
                                (ANSC_HANDLE)pBmoRep
                            );

                    break;

            default :

                    if ( pProperty->OwnerFlag & WEB_ROO_FLAG_UPNP_SUPPORT )
                    {
                        if ( pBmoReq->GetMethod((ANSC_HANDLE)pBmoReq) == HTTP_METHOD_CODE_NOTIFY )
                        {
                            returnStatus =
                                pMyObject->DoNotify
                                    (
                                        (ANSC_HANDLE)pMyObject,
                                        (ANSC_HANDLE)pBmoReq,
                                        (ANSC_HANDLE)pBmoRep
                                    );

                            break;
                        }
                        else if ( pBmoReq->GetMethod((ANSC_HANDLE)pBmoReq) == HTTP_METHOD_CODE_SEARCH )
                        {
                            returnStatus =
                                pMyObject->DoSearch
                                    (
                                        (ANSC_HANDLE)pMyObject,
                                        (ANSC_HANDLE)pBmoReq,
                                        (ANSC_HANDLE)pBmoRep
                                    );

                            break;
                        }
                        else if ( pBmoReq->GetMethod((ANSC_HANDLE)pBmoReq) == HTTP_METHOD_CODE_M_SEARCH )
                        {
                            returnStatus =
                                pMyObject->DoMSearch
                                    (
                                        (ANSC_HANDLE)pMyObject,
                                        (ANSC_HANDLE)pBmoReq,
                                        (ANSC_HANDLE)pBmoRep
                                    );

                            break;
                        }
                        else if ( pBmoReq->GetMethod((ANSC_HANDLE)pBmoReq) == HTTP_METHOD_CODE_M_POST )
                        {
                            returnStatus =
                                pMyObject->DoMPost
                                    (
                                        (ANSC_HANDLE)pMyObject,
                                        (ANSC_HANDLE)pBmoReq,
                                        (ANSC_HANDLE)pBmoRep
                                    );

                            break;
                        }
                        else if ( pBmoReq->GetMethod((ANSC_HANDLE)pBmoReq) == HTTP_METHOD_CODE_SUBSCRIBE )
                        {
                            returnStatus =
                                pMyObject->DoSubscribe
                                    (
                                        (ANSC_HANDLE)pMyObject,
                                        (ANSC_HANDLE)pBmoReq,
                                        (ANSC_HANDLE)pBmoRep
                                    );

                            break;
                        }
                        else if ( pBmoReq->GetMethod((ANSC_HANDLE)pBmoReq) == HTTP_METHOD_CODE_UNSUBSCRIBE )
                        {
                            returnStatus =
                                pMyObject->DoUnsubscribe
                                    (
                                        (ANSC_HANDLE)pMyObject,
                                        (ANSC_HANDLE)pBmoReq,
                                        (ANSC_HANDLE)pBmoRep
                                    );

                            break;
                        }
                    }

                    returnStatus =
                        pMyObject->ReplyReq
                            (
                                (ANSC_HANDLE)pMyObject,
                                (ANSC_HANDLE)pBmoReq,
                                (ANSC_HANDLE)pBmoRep,
                                HTTP_STATUS_NOT_IMPLEMENTED,
                                (ANSC_HANDLE)NULL
                            );

                    break;
        }
    }

    /******************************************************************
                GRACEFUL ROLLBACK PROCEDURES AND EXIT DOORS
    ******************************************************************/

EXIT1:

    AnscDelTokenChain((ANSC_HANDLE)pPathTokenChain);
    AnscFreeMemory   ((ANSC_HANDLE)pPathTokenChain);

    return  returnStatus;
}
コード例 #2
0
ANSC_STATUS
HttpBmoSaveFormAsFile
    (
        ANSC_HANDLE                 hThisObject,
        char*                       param_name,
        char*                       file_name,
        BOOL                        bFlushBody
    )
{
    ANSC_STATUS                     returnStatus = ANSC_STATUS_SUCCESS;
    PHTTP_BASIC_MESSAGE_OBJECT      pMyObject    = (PHTTP_BASIC_MESSAGE_OBJECT)hThisObject;
    PHTTP_BMO_REQ_OBJECT            pBmoReq      = (PHTTP_BMO_REQ_OBJECT      )pMyObject;
    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_RCP_INTERFACE             pRcpIf       = (PHTTP_RCP_INTERFACE          )pBmoReq->hRcpIf;
    PHTTP_FUM_INTERFACE             pFumIf       = (PHTTP_FUM_INTERFACE       )pMyObject->hFumIf;
    PHTTP_MDH_INTERFACE             pMdhIf       = (PHTTP_MDH_INTERFACE       )NULL;
    PHTTP_MESSAGE_BODY_OBJECT       pMessageBody = (PHTTP_MESSAGE_BODY_OBJECT )pMyObject->hMessageBody;
    char*                           pBoundaryStr = NULL;
    ULONG                           ulEncType    = HTTP_HFP_FORM_ENCTYPE_URLENCODED;
    ULONG                           ulMediaType  = IANA_MEDIA_TYPE_CODE_APPLICATION;
    ULONG                           ulSubType    = IANA_MT_AP_STYPE_CODE_X_FORM_URLENCODED;
    char*                           pReqUri      = pRcpIf->GetPathInfo(pRcpIf->hOwnerContext, (ANSC_HANDLE)pMyObject);

    pMdhIf = (PHTTP_MDH_INTERFACE)pFumIf->GetMdhIf(pFumIf->hOwnerContext, pReqUri);

    if ( pMdhIf )
    {
        return
            pMdhIf->SaveFileAs
                (
                    pMdhIf->hOwnerContext,
                    pBmoReq->GetWebSessionId((ANSC_HANDLE)pBmoReq),
                    pReqUri,
                    param_name,
                    file_name
                );
    }

    if ( !pMessageBody || (pMyObject->Oid != HTTP_BMO_REQ_OID) )
    {
        return  ANSC_STATUS_UNAPPLICABLE;
    }
    else if ( pBmoReq->GetMethod((ANSC_HANDLE)pBmoReq) != HTTP_METHOD_CODE_POST )
    {
        return  ANSC_STATUS_UNAPPLICABLE;
    }

    if ( TRUE )
    {
        returnStatus =
        	HttpBmoReqCgiGetContentType
                (
                    (ANSC_HANDLE)pBmoReq,
                    &ulMediaType,
                    &ulSubType
                );

        if ( (ulMediaType == IANA_MEDIA_TYPE_CODE_APPLICATION       ) &&
             (ulSubType   == IANA_MT_AP_STYPE_CODE_X_FORM_URLENCODED) )
        {
            ulEncType = HTTP_HFP_FORM_ENCTYPE_URLENCODED;
        }
        else if ( (ulMediaType == IANA_MEDIA_TYPE_CODE_MULTIPART ) &&
                  (ulSubType   == IANA_MT_MP_STYPE_CODE_FORM_DATA) )
        {
            ulEncType    = HTTP_HFP_FORM_ENCTYPE_MULTIPART;
            pBoundaryStr = HttpBmoReqCgiGetBoundaryDelimiter((ANSC_HANDLE)pBmoReq);

            if ( !pBoundaryStr )
            {
                return  ANSC_STATUS_UNAPPLICABLE;
            }
        }
        else
        {
            return  ANSC_STATUS_UNAPPLICABLE;
        }
    }

    returnStatus =
        pHfpIf->SaveFormPartAsFile
            (
                pHfpIf->hOwnerContext,
                param_name,
                file_name,
                ulEncType,
                pBoundaryStr,
                (ANSC_HANDLE)pMessageBody,
                bFlushBody
            );

    if ( pBoundaryStr )
    {
        AnscFreeMemory(pBoundaryStr);
    }

    return  returnStatus;
}