12 #ifndef __NET_WEBRESPONSE_H__
13 #define __NET_WEBRESPONSE_H__
112 explicit operator bool()
const {
return isSuccess(); }
129 auto it = myHeaders.find(header);
130 if (it == myHeaders.end())
138 if (it == myHeaders.end())
151 bool hasJSONBody()
const;
152 static bool isJSONBody(
const HeaderMap &headers);
268 template <>
struct is_error_code_enum<NET::
CurlError> : true_type
303 return myError.myErrorCode
376 bool isFile()
const {
return myFile.isstring(); }
412 for (
auto&& header : headers)
414 setHeader(header.first, header.second);
427 if (!content_type.isEmpty())
428 myContentType = content_type;
429 else if (myContentType.isEmpty())
430 myContentType =
"text/plain";
431 myContentLength = myData.
length();
440 myHasMoreData = has_more;
446 setBody(body,
"text/plain");
450 setBody(body,
"application/json");
461 myDeleteFile =
false;
474 myBoundary.format(
"-----{}",
time(
nullptr) ^ (
uint64)(
this));
537 myContentType.clear();
542 myDeleteFile =
false;
550 myHasMoreData =
false;
557 friend class NET_HttpIO;
563 exint myContentLength;
566 unsigned myDeleteFile : 1;
567 unsigned myUpgrade : 1;
568 unsigned myChunked : 1;
569 unsigned myHasMoreData : 1;
570 unsigned myKeepAlive : 1;
577 #endif // __NET_WEBRESPONSE_H__
NET_HTTPStatusCode status() const
const UT_StringHolder & contentTypeOrEmpty() const
void setDefault(const UT_StringHolder &name, const UT_StringHolder &value)
Response object used for responding to request in the server.
void setErrors(const UT_StringHolder &errors)
GT_API const UT_StringHolder time
NET_API const UT_ErrorCategory & GetCurlErrorCategory()
void setKeepAlive(bool keep_alive)
NET_WebResponse(NET_HTTPStatusCode code, const UT_StringHolder &data)
std::error_category UT_ErrorCategory
unsigned long long uint64
const UT_StringHolder & getHeaderOrEmpty(const UT_StringRef &header) const
std::optional< T > UT_Optional
void setRanges(const NET_RequestRangeList &ranges)
UT_ErrorCode make_error_code(NET::CurlError e)
void setText(const UT_StringHolder &body)
bool hasHeader(const UT_StringRef &header) const
Response object used by a client from a response by a server.
void setStatus(NET_HTTPStatusCode code)
std::shared_ptr< T > UT_SharedPtr
Wrapper around std::shared_ptr.
bool isRequestNotFound() const
static const UT_StringHolder theEmptyString
void setJSON(const UT_StringHolder &body)
void setDefault(const UT_StringHolder &name, const UT_StringHolder &value)
const HeaderMap & headers() const
UT_SharedPtr< NET_WebResponse > NET_WebResponseSPtr
UT_ArrayStringMap< UT_StringHolder > HeaderMap
const UT_StringHolder & boundary() const
GLuint const GLchar * name
UT_StringHolder myErrorMsg
NET_WebResponse(NET_HTTPStatusCode code, const HeaderMap &headers, const UT_StringHolder &data)
#define HTTP_ACCEPT_RANGES
NET_HTTPStatusCode myStatus
std::error_code UT_ErrorCode
NET_WebResponse(NET_HTTPStatusCode code)
exint entries() const
Alias of size(). size() is preferred.
NET_API UT_StringHolder NETextraDetails(const UT_ErrorCode &ec)
#define HTTP_LAST_MODIFIED
NET_WebResponse & operator=(const NET_HTTPResponse &resp)
void setBody(const UT_StringHolder &body, const UT_StringRef &content_type="")
LeafData & operator=(const LeafData &)=delete
const NET_RequestRangeList & ranges() const
const UT_StringHolder & data() const
void setHeaders(const HeaderMap &headers)
const UT_StringHolder & getHeaderOrEmpty(const UT_StringRef &header) const
exint contentLength() const
NET_WebResponse(NET_HTTPStatusCode code, const HeaderMap &headers)
void setBodyChunk(const UT_StringHolder &body, bool has_more=false)
bool errorReceivedNothing() const
const UT_StringHolder & file() const
bool hasHeader(const UT_StringRef &header) const
void clear()
Resets list to an empty list.
const UT_StringHolder & contentType() const
#define HTTP_CONTENT_TYPE
bool isBadRequest() const
NET_WebResponse(const NET_HTTPResponse &resp)