2#include "MRMesh/MRMeshFwd.h"
3#if defined( __EMSCRIPTEN__ ) || !defined( MRMESH_NO_CPR )
6#include <unordered_map>
45 MRVIEWER_API
void setParameters( std::unordered_map<std::string, std::string> parameters );
48 MRVIEWER_API
void setHeaders( std::unordered_map<std::string, std::string> headers );
65 MRVIEWER_API
void setFormData( std::vector<FormData> formData );
68 MRVIEWER_API
void setBody( std::string body );
88 MRVIEWER_API
void send( std::string url, std::string logName,
ResponseCallback callback,
bool async =
true );
95 Method method_{ Method::Get };
99 int timeout_{ 10000 };
100 std::unordered_map<std::string, std::string> params_;
101 std::unordered_map<std::string, std::string> headers_;
102 std::filesystem::path inputPath_;
103 std::vector<FormData> formData_;
105 std::filesystem::path outputPath_;
106 ProgressCallback uploadCallback_;
107 ProgressCallback downloadCallback_;
this class is needed to unify cpp and wasm requests
Definition MRWebRequest.h:21
std::string path
Definition MRWebRequest.h:60
MRVIEWER_API void setAsync(bool async)
set async mode (return immediately after sending request)
MRVIEWER_API void send(ResponseCallback callback)
MRVIEWER_API void clear()
clear all request data
MR::WebResponseCallback ResponseCallback
Definition MRWebRequest.h:82
MRVIEWER_API void setFormData(std::vector< FormData > formData)
MRVIEWER_API void setOutputPath(std::filesystem::path outputPath)
prefer to save the response to file
tl::expected< T, E > Expected
Definition MRExpected.h:31
MRVIEWER_API void setInputPath(std::filesystem::path inputPath)
set path to the file to upload
std::string name
Definition MRWebRequest.h:62
MRVIEWER_API void setBody(std::string body)
set payload in plain format
MRVIEWER_API void setUploadProgressCallback(ProgressCallback callback)
std::string fileName
Definition MRWebRequest.h:63
std::function< void(const Json::Value &response)> WebResponseCallback
Definition MRWebResponseCallback.h:12
MRVIEWER_API WebRequest(std::string url)
MRVIEWER_API void send(std::string url, std::string logName, ResponseCallback callback, bool async=true)
MRVIEWER_API void setMethod(Method method)
set HTTP method
Method
Definition MRWebRequest.h:27
MRVIEWER_API void setHeaders(std::unordered_map< std::string, std::string > headers)
set HTTP headers
MRVIEWER_API void setLogName(std::string logName)
set log name
MRVIEWER_API Expected< Json::Value > parseResponse(const Json::Value &response)
returns json value of text or error if response failed
static MRVIEWER_API void waitRemainingAsync()
if any async request is still in progress, wait for it
MRVIEWER_API void setDownloadProgressCallback(ProgressCallback callback)
set progress callback for download
std::string contentType
Definition MRWebRequest.h:61
MRVIEWER_API void setParameters(std::unordered_map< std::string, std::string > parameters)
set URL query parameters
MRVIEWER_API void setTimeout(int timeoutMs)
set timeout in milliseconds
only for bindings generation
Definition MRCameraOrientationPlugin.h:8