Syntax
Parameters
call   _In_Type: HCMockCallHandle This HC_MOCK_CALL_HANDLE that represents the mock that has been configured accordingly using HCMockResponseSet*() method   _In_opt_z_
Type: char* The UTF-8 encoded HTTP method. Pass it together with url to limit the mock to specific URLs. The method isn’t used for matching. url   _In_opt_z_
Type: char* The UTF-8 encoded URL prefix to match. The URL condition is set only when both method and url aren’t
nullptr.
requestBodyBytes   _In_reads_bytes_opt_(requestBodySize)Type: uint8_t* If you want the mock to only apply to a specific URL & request string, pass in a method, URL and a string body. requestBodySize   _In_
Type: uint32_t The size of requestBodyBytes in bytes.
Return value
Type: HRESULT Result code for this API operation. Possible values are S_OK, E_INVALIDARG, E_OUTOFMEMORY, E_HC_NOT_INITIALISED, or E_FAIL. Returns E_HC_NOT_INITIALISED if libHttpClient isn’t initialized; call HCInitialize first.Remarks
To define a mock response, create a mock handle with HCMockCallCreate, and then set the response with the HCMockResponseSet* functions. Then add the mock by calling HCMockAddMock. On a newly created mock, omit both method and url to match every call. To set a URL-prefix condition, pass both a non-null method and a nonempty url. Matching ignores the method. An empty stored URL matches every call and ignores any body condition. Null arguments don’t clear criteria already stored on a reused mock. With a nonempty stored URL and a nonempty body filter, matching compares the buffered request-body bytes exactly. A non-null requestBodyBytes with a zero requestBodySize is invalid. If a request supplies its body only through a custom body read function, don’t rely on the body filter. Omit the body filter and inspect the request body in an HCMockMatchedCallback instead. You can add more than one mock that matches the same call. libHttpClient selects a mock for each request attempt, including automatic retries. If only one mock matches, libHttpClient uses that mock every time. If more than one mock matches, libHttpClient cycles through the matching mocks in the order that you added them, and starts again with the first after the last. libHttpClient tracks this position separately for each method and URL pair of the original call. A successful call to HCMockRemoveMock or HCMockClearMocks resets the position for all calls. Each successful call to HCMockAddMock retains a reference to the mock. Removing a registration with HCMockRemoveMock, or clearing all registrations with HCMockClearMocks, releases the corresponding retained references. You still need to close your own handle with HCMockCallCloseHandle. To change the response when a mock is matched, register an HCMockMatchedCallback with HCMockSetMockMatchedCallback.Requirements
Header: mock.h Library: libHttpClient.lib Supported platforms: Windows, XBOX One family consoles and XBOX Series consolesSee also
mockHCMockMatchedCallback
HCMockRemoveMock
HCMockClearMocks
