Freigeben über


CHttpFile::SendRequestEx

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 Windows 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.

Return Value

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

Remarks

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.

Exceptions

This method can throw exceptions of type CInternetException*.

Example

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

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

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

Requirements

Header: afxinet.h

See Also

Concepts

CHttpFile Class

CHttpFile Members

Hierarchy Chart

CInternetFile Class

CHttpFile::SendRequest