Help Center

CWinHttpRequest.GetResponseBodymethod

Retrieves the response entity body as an array of unsigned bytes.

COMmethoddocumented

Syntax

FUNCTION GetResponseBody () AS STRING

Return value

An string containing the response entity body as an array of unsigned bytes. This array contains the raw data as received directly from the server.

Description

Retrieves the response entity body as an array of unsigned bytes.

Remarks

This method returns the response data in an array of unsigned bytes. If the response does not have a response body, an empty variant is returned. This method can only be invoked after the Send method has been called.

Examples

#cmdline "-s console" #include once "AfxNova/CWinHttpRequest.inc" using AfxNova

' // Create an instance of the CWinHttp class DIM pWHttp AS CWinHttpRequest

' // Open an HTTP connection to an HTTP resource pWHttp.Open "GET", "http://microsoft.com"

' // Send an HTTP request to the HTTP server pWHttp.Send

' // Wait for response with a timeout of 5 seconds DIM iSucceeded AS LONG = pWHttp.WaitForResponse(5)

' // Get the response body DIM strResponseBody AS STRING = pWHttp.GetResponseBody PRINT strResponseBody

#cmdline "-s console" #include once "AfxNova/CWinHttpRequest.inc" #include once "Afx/CStream.inc" using AfxNova

' // Create an instance of the CWinHttp class DIM pWHttp AS CWinHttpRequest

' // Open an HTTP connection to an HTTP resource pWHttp.Open "GET", "https://learn.microsoft.com/en-us/archive/msdn-magazine/2012/october/images/jj658963.banner.png"

' // Send an HTTP request to the HTTP server pWHttp.Send

' // Wait for response with a timeout of 5 seconds DIM iSucceeded AS LONG = pWHttp.WaitForResponse(5)

' // Get the response body as an array of unsigned bytes. DIM strResponseBody AS STRING = pWHttp.GetResponseBody

' // Open a file stream DIM pFileStream AS CFileStream IF pFileStream.Open("image.png", STGM_CREATE OR STGM_WRITE) = S_OK then pFileStream.WriteTextA(strResponseBody) END IF

Reference

  • Defined in AfxNova/CWinHttpRequest.inc:274
  • Documented in COM/CWinHttpRequest Class.md
  • Topic: CWinHttpRequest Class