Export (0) Print
Expand All

CHttpFile::SendRequestEx 

This topic has been updated for Visual Studio 2005 SP1.

Call this member function to send a request to an HTTP server.


BOOL SendRequestEx(
   DWORD dwTotalLen,
   DWORD dwFlags = HSR_INITIATE,
   DWORD_PTR dwContext = 1 
);
BOOL SendRequestEx(
   LPINTERNET_BUFFERS lpBuffIn,
   LPINTERNET_BUFFERS lpBuffOut,
   DWORD dwFlags = HSR_INITIATE,
   DWORD_PTR dwContext = 1 
);

Parameters

dwTotalLen

Number of bytes to be sent in the request.

dwFlags

Flags describing the operation. For a list of appropriate flags, see HttpSendRequestEx in the Platform SDK.

dwContext

The context identifier for the CHttpFile operation. See Remarks for more information about this parameter.

lpBuffIn

Pointer to an initialized INTERNET_BUFFERS that describes the input buffer used for the operation.

lpBuffOut

Pointer to an initialized INTERNET_BUFFERS that describes the output buffer used for the operation.

Nonzero if successful; otherwise 0. If the call fails, determine the cause of the failure by examining the thrown CInternetException object.

This function allows your application to send data using the Write and WriteString methods of CInternetFile. You must know the length of the data to send before calling either override of this function. The first override allows you to specify the length of data you'd like to send. The second override accepts pointers to INTERNET_BUFFERS structures, which can be used to describe the buffer in great detail.

After content is written to the file, call EndRequest to end the operation.

The default value for dwContext is sent by MFC to the CHttpFile object from the CInternetSession object that created the CHttpFile object. When you call CInternetSession::OpenURL or CHttpConnection to construct a CHttpFile object, you can override the default to set the context identifier to a value of your choosing. The context identifier is returned to CInternetSession::OnStatusCallback to provide status on the object with which it is identified. See the article Internet First Steps: WinInet for more information about the context identifier.

This method can throw exceptions of type CInternetException*.

This code fragment sends the content of a string to a DLL named ISAPI.DLL on a server named MOOSEBOY. While this example uses only one call to WriteString, using multiple calls to send data in blocks is acceptable.

CString strData = "Some very long data to be POSTed here!";
pServer = sess.GetHttpConnection("mooseboy");
pFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_POST, "/isapi.dll?");
pFile->SendRequestEx(strData.GetLength());

pFile->WriteString(strData);   
pFile->EndRequest();

This section has been updated for Visual Studio 2005 SP1.

This method is not supported in Smart Device projects.

Community Additions

ADD
Show:
© 2014 Microsoft