how to get post date in isapi extension? when data is large.RSS

8 replies

Last post Nov 09, 2009 04:34 AM by kylekou

  • how to get post date in isapi extension? when data is large.

    Oct 27, 2009 01:31 AM|kylekou|LINK

    HttpExtensionProc(EXTENSION_CONTROL_BLOCK *pECB)

    in this method , how get post data?

    thanks in advance!

  • Re: how to get post date in isapi extension? when data is large.

    Oct 27, 2009 01:32 PM|anilr|LINK

    You can use either pECB->ReadClient(...) or pECB->ServerSupportFunction(..., HSE_REQ_ASYNC_READ_CLIENT, ...) - you can find further documentation on msdn.

    Anil Ruia
    Software Design Engineer
    IIS Core Server
  • Re: how to get post date in isapi extension? when data is large.

    Oct 27, 2009 09:32 PM|kylekou|LINK

     

    thans, i post my code here, there is something wrong with it, though i can get whole post data, but can't set post back to next request, the web site page can't show.

       ISAPI_REQUEST request(pECB);
       ISAPI_BUFFER buffEntity;
       ISAPI_STRING strData;
       CString strBuffer2;
       long nContentLength;
       
       if (request.GetServerVariable("CONTENT_LENGTH", &strData))
       {
        nContentLength = atol(strData.QueryStr());
        if (nContentLength > 0)
        {
         buffEntity.SetMaxAlloc(nContentLength);
         
         if (!request.ReadAllEntity(&buffEntity))
         {
          OutputDebugString("request body get fail, too big!");
          return process_original_url(pECB);
         }
        }
       } else {
        OutputDebugString("request body length get fail!");
        return process_original_url(pECB);
       }
       
       char *tmp = (char*)malloc(nContentLength);
       memset(tmp, 0, nContentLength);
       strcpy(tmp, (char*)buffEntity.QueryPtr());

       struffer2 = tmp;
       if(NULL != tmp)
         {
          delete tmp;
          tmp = NULL;
         } 
      
         return SetRequestPackage(pECB, buffEntity, request.IsCallReadClient());

    DWORD SetRequestPackage(EXTENSION_CONTROL_BLOCK *pecb, ISAPI_BUFFER buffEntity, bool flag)
    {
     HSE_EXEC_URL_INFO* pExecUrlInfo = new HSE_EXEC_URL_INFO;
     if(NULL == pExecUrlInfo)
     {
      return HSE_STATUS_ERROR;
     }
     ZeroMemory( pExecUrlInfo, sizeof( HSE_EXEC_URL_INFO ) );
     pExecUrlInfo->pszUrl   = NULL;  //URL
     pExecUrlInfo->pszMethod   = NULL;  //method
     pExecUrlInfo->pszChildHeaders = NULL;  //header
     pExecUrlInfo->pUserInfo   = NULL;  //user info
     pExecUrlInfo->pEntity   = NULL;  //body

     pExecUrlInfo->dwExecUrlFlags = HSE_EXEC_URL_IGNORE_CURRENT_INTERCEPTOR;

     EXTENSION_DATA* ped = new EXTENSION_DATA;
     ped->pHEUI = pExecUrlInfo;
     ped->pBody = NULL;

     if(flag)
     {
      DWORD dwSize = buffEntity.QueryDataSize();
      ped->pBody = (char*)buffEntity.QueryPtr();
      HSE_EXEC_URL_ENTITY_INFO* pEntityInfo = new HSE_EXEC_URL_ENTITY_INFO;
      pEntityInfo->lpbData = (void*)ped->pBody;
      pEntityInfo->cbAvailable = dwSize;
      pExecUrlInfo->pEntity = pEntityInfo;
     }
     
     if ( pecb->ServerSupportFunction(pecb->ConnID, HSE_REQ_IO_COMPLETION, HandleCompletion, NULL, (LPDWORD)ped) == FALSE) {
      WriteLog("ServerSupportFunction1");
      return SyncSendGenericServerError(pecb);
      }
     
     if ( pecb->ServerSupportFunction( pecb->ConnID, HSE_REQ_EXEC_URL, pExecUrlInfo, NULL, NULL) == FALSE) {
      WriteLog("ServerSupportFunction2");
      return SyncSendGenericServerError(pecb);
     }

     return HSE_STATUS_PENDING;
    }

    can anybody give me some advice?

  • Re: how to get post date in isapi extension? when data is large.

    Oct 28, 2009 08:11 AM|anilr|LINK

    Note that upto 48k of data (by default) is pre-read in pECB->lpbData/cbAvailable - also, if you are just reading the data to pass it along to ECEC_URL, you need not do that - just pass the pre-loaded data, the rest will be automatically passed along.

    Anil Ruia
    Software Design Engineer
    IIS Core Server
  • Re: how to get post date in isapi extension? when data is large.

    Oct 28, 2009 10:07 PM|kylekou|LINK

    i don't want modify data, do you mean this SetRequestPackage() no need ?

    just return the predata?  how return the data? i can't find a right way? please help me !

  • Re: how to get post date in isapi extension? when data is large.

    Oct 29, 2009 08:03 PM|anilr|LINK

    Just do

    pEntityInfo->lpbData = pECB->lpbData;
    pEntityInfo->cbAvailable = pECB->cbAvailable;

    Anil Ruia
    Software Design Engineer
    IIS Core Server
  • Re: how to get post date in isapi extension? when data is large.

    Oct 29, 2009 10:01 PM|kylekou|LINK

    DWORD SetRequestPackage(EXTENSION_CONTROL_BLOCK *pecb, ISAPI_BUFFER buffEntity, bool flag)
    {
     HSE_EXEC_URL_INFO* pExecUrlInfo = new HSE_EXEC_URL_INFO;
     if(NULL == pExecUrlInfo)
     {
      return HSE_STATUS_ERROR;
     }
     ZeroMemory( pExecUrlInfo, sizeof( HSE_EXEC_URL_INFO ) );
     pExecUrlInfo->pszUrl   = NULL;  //URL
     pExecUrlInfo->pszMethod   = NULL;  //method
     pExecUrlInfo->pszChildHeaders = NULL;  //header
     pExecUrlInfo->pUserInfo   = NULL;  //user info
     pExecUrlInfo->pEntity   = NULL;  //body

     pExecUrlInfo->dwExecUrlFlags = HSE_EXEC_URL_IGNORE_CURRENT_INTERCEPTOR;

     if(flag)
     {
      HSE_EXEC_URL_ENTITY_INFO* pEntityInfo = new HSE_EXEC_URL_ENTITY_INFO;
      pEntityInfo->lpbData = pecb->lpbData;
      pEntityInfo->cbAvailable = pecb->cbAvailable;
      pExecUrlInfo->pEntity = pEntityInfo;
     }
     
     if ( pecb->ServerSupportFunction(pecb->ConnID, HSE_REQ_IO_COMPLETION, HandleCompletion, NULL, (LPDWORD)pExecUrlInfo) == FALSE) {
      WriteLog("ServerSupportFunction1");
      return SyncSendGenericServerError(pecb);
      }
     
     if ( pecb->ServerSupportFunction( pecb->ConnID, HSE_REQ_EXEC_URL, pExecUrlInfo, NULL, NULL) == FALSE) {
      WriteLog("ServerSupportFunction2");
      return SyncSendGenericServerError(pecb);
     }

     return HSE_STATUS_PENDING;
    }

     when i change like this , only 16k data be post, else loss,  if  pecb->cbAvailable change pecb->cbTotalBytes or not ?

  • Re: how to get post date in isapi extension? when data is large.

    Nov 07, 2009 03:21 AM|anilr|LINK

    The above should work - I am not sure what to suggest to troubleshoot further.

    Anil Ruia
    Software Design Engineer
    IIS Core Server
  • Re: how to get post date in isapi extension? when data is large.

    Nov 09, 2009 04:34 AM|kylekou|LINK

    appreciate for your help!

    i find the mistake , because i don't use dynamic malloc memory.

    ISAPI_BUFFER *buffEntity = new ISAPI_BUFFER; then , it work correctly.