L_InetHttpSendRequest

#include "ltweb.h"

L_INT EXT_FUNCTION L_InetHttpSendRequest(hHttp, pszHeader,ulHeaderSize, pszOptional, ulOptionalSize)

HINET hHttp;

/* handle to an HTTP connection*/

L_TCHAR L_FAR *pszHeader;

/* pointer to header data*/

L_UINT32 ulHeaderSize;

/* sizeof the header data*/

L_TCHAR L_FAR *pszOptional;

/* optional data*/

L_UINT32 ulOptionalSize;

/* sizeof the optional data*/

Sends an HTTP request to the HTTP server.

Parameter

Description

hHttp

Handle to the HTTP connection. It is the same handle obtained using the L_InetHttpConnect function.

pszHeader

Pointer to any additional header data to be sent along with the request. This value can be NULL.

ulHeaderSize

Size of the data in pszHeader.

pszOptional

Pointer to any optional data to be sent after the HTTP header.

ulOptionalSize

Size of the data in pszOptional.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

This function can be used to send a request when it is not necessary to send additional data.

Required DLLs and Libraries

LTWEB

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application

See Also

Functions:

L_InetHttpSendBitmap, L_InetHttpSendData, L_InetHttpSendForm

Topics:

HTTP Functions: Sending Data Over a HTTP Connection

 

Working with HTTP Functions

Example

void TestSendRequest()
{
   HINET hInet;
   L_INT nRet;

   nRet = L_InetHttpConnect(TEXT("www.leadtools.com"),80,TEXT(""),TEXT(""),&hInet);
   if(nRet==SUCCESS)
   {
      nRet = L_InetHttpOpenRequest(hInet,HTTP_GET,TEXT("/default.htm"),TEXT(""), TEXT("HTTP/1.0"),0);
      if(nRet==SUCCESS)
      {
         L_TCHAR szResponse[2048];
         L_UINT32 lsize;
         L_UINT uStatus;
         FILE *fp;
   
         nRet=L_InetHttpSendRequest(hInet,NULL,0,NULL,0);
         if(nRet!=SUCCESS)
         {
            MessageBox(NULL,TEXT("Error Sending Form"),TEXT("Error"),MB_ICONEXCLAMATION);
            L_InetHttpCloseRequest(hInet);
            L_InetHttpDisconnect(hInet);
            return;
         }

         L_InetHttpGetServerStatus(hInet,&uStatus);
         if(uStatus==L_HTTP_STATUS_OK)
         {
            lsize = 2048;
            L_InetHttpGetResponse(hInet,szResponse,&lsize);
            #ifdef UNICODE

               fp = _wfopen(TEXT("output.htm"),TEXT("wb"));
            #else

               fp = fopen("output.htm","wb");
            #endif

            while(lsize!=0)
            {
               fwrite(szResponse,lsize,1,fp);
               lsize = 1048;
               L_InetHttpGetResponse(hInet,szResponse,&lsize);
            }
            fclose(fp);
         }
         else
         {
            MessageBox(NULL,TEXT("Problem With Server"),TEXT("Error"),MB_ICONEXCLAMATION);
            lsize = 2048;
            L_InetHttpGetResponse(hInet,szResponse,&lsize);
            #ifdef UNICODE

               fp = _wfopen(TEXT("error.htm"),TEXT("wb"));
            #else

               fp = fopen("error.htm","wb");
            #endif

            while(lsize!=0)
            {
               fwrite(szResponse,lsize,1,fp);
               lsize = 1048;
               L_InetHttpGetResponse(hInet,szResponse,&lsize);
            }
            fclose(fp);
         }
         L_InetHttpCloseRequest(hInet);
      }
      L_InetHttpDisconnect(hInet);
   }
}