browser wasm
This commit is contained in:
parent
28fab2509b
commit
e8630528af
24 changed files with 2490 additions and 100 deletions
|
|
@ -32,6 +32,12 @@ namespace Crafter {
|
|||
//
|
||||
// For local development against a self-signed listener, pass
|
||||
// QUICClientCredentials{insecureNoServerValidation = true}.
|
||||
//
|
||||
// Browser build: the request is dispatched via the browser's fetch()
|
||||
// and the synchronous Send() is not compiled — use SendAsync instead.
|
||||
// The ClientHTTP instance does not maintain a persistent connection
|
||||
// (fetch is request-scoped); host and port are stored and prefixed to
|
||||
// the request path on each call. QUICClientCredentials is ignored.
|
||||
export class ClientHTTP {
|
||||
public:
|
||||
std::string host;
|
||||
|
|
@ -44,8 +50,18 @@ namespace Crafter {
|
|||
ClientHTTP(const ClientHTTP&) = delete;
|
||||
ClientHTTP(ClientHTTP&&) noexcept;
|
||||
|
||||
#ifndef CRAFTER_NETWORK_BROWSER
|
||||
// Send a request and synchronously read back the full response.
|
||||
HTTPResponse Send(const HTTPRequest& request);
|
||||
#endif
|
||||
|
||||
// Send a request and deliver the response (or an error) via callback.
|
||||
// Available on both native and browser builds. Native dispatches on
|
||||
// Crafter.Thread's ThreadPool; browser uses fetch() and resolves on
|
||||
// the JS event loop.
|
||||
void SendAsync(const HTTPRequest& request,
|
||||
std::function<void(HTTPResponse)> onSuccess,
|
||||
std::function<void(std::string)> onError);
|
||||
|
||||
private:
|
||||
struct Impl;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue