Android-cuttlefish cvd tool
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
cuttlefish::FakeHttpClient Class Reference

#include <fake_http_client.h>

Inheritance diagram for cuttlefish::FakeHttpClient:
Inheritance graph
[legend]
Collaboration diagram for cuttlefish::FakeHttpClient:
Collaboration graph
[legend]

Public Types

using Handler = std::function< HttpResponse< std::string >(const HttpRequest &)>
 
- Public Types inherited from cuttlefish::HttpClient
typedef std::function< bool(char *, size_t)> DataCallback
 

Public Member Functions

void SetResponse (std::string data, std::string url="")
 
void SetResponse (Handler handler, std::string url="")
 
Result< HttpResponse< void > > DownloadToCallback (HttpRequest request, HttpClient::DataCallback callback) override
 
- Public Member Functions inherited from cuttlefish::HttpClient
virtual ~HttpClient ()
 
virtual Result< HttpResponse< void > > DownloadToCallback (HttpRequest, DataCallback callback)=0
 

Private Member Functions

const HandlerFindHandler (std::string_view url) const
 

Private Attributes

std::mutex mutex_
 
std::unordered_map< std::string, Handlerresponses_
 

Member Typedef Documentation

◆ Handler

using cuttlefish::FakeHttpClient::Handler = std::function<HttpResponse<std::string>(const HttpRequest&)>

Member Function Documentation

◆ DownloadToCallback()

Result< HttpResponse< void > > cuttlefish::FakeHttpClient::DownloadToCallback ( HttpRequest  request,
HttpClient::DataCallback  callback 
)
overridevirtual

◆ FindHandler()

const FakeHttpClient::Handler * cuttlefish::FakeHttpClient::FindHandler ( std::string_view  url) const
private

◆ SetResponse() [1/2]

void cuttlefish::FakeHttpClient::SetResponse ( FakeHttpClient::Handler  handler,
std::string  url = "" 
)

◆ SetResponse() [2/2]

void cuttlefish::FakeHttpClient::SetResponse ( std::string  data,
std::string  url = "" 
)

Member Data Documentation

◆ mutex_

std::mutex cuttlefish::FakeHttpClient::mutex_
private

◆ responses_

std::unordered_map<std::string, Handler> cuttlefish::FakeHttpClient::responses_
private

The documentation for this class was generated from the following files: