Use QByteArray directly in HTTPRequest::set_{payload,header}

This commit is contained in:
Mm2PL 2024-10-09 23:07:27 +02:00
parent 557e50f310
commit 16da304d78
No known key found for this signature in database
GPG key ID: 94AC9B80EFA15ED9
2 changed files with 6 additions and 9 deletions

View file

@ -69,18 +69,15 @@ void HTTPRequest::finally(sol::protected_function func)
this->cbFinally = std::make_optional(func); this->cbFinally = std::make_optional(func);
} }
void HTTPRequest::set_payload(const std::string &payload) void HTTPRequest::set_payload(QByteArray payload)
{ {
this->req_ = this->req_ = std::move(this->req_).payload(payload);
std::move(this->req_).payload(QByteArray::fromStdString(payload));
} }
// name and value may be random bytes // name and value may be random bytes
void HTTPRequest::set_header(std::string name, std::string value) void HTTPRequest::set_header(QByteArray name, QByteArray value)
{ {
this->req_ = std::move(this->req_) this->req_ = std::move(this->req_).header(name, value);
.header(QByteArray::fromStdString(name),
QByteArray::fromStdString(value));
} }
std::shared_ptr<HTTPRequest> HTTPRequest::create(sol::this_state L, std::shared_ptr<HTTPRequest> HTTPRequest::create(sol::this_state L,

View file

@ -96,7 +96,7 @@ public:
* @lua@param data string * @lua@param data string
* @exposed HTTPRequest:set_payload * @exposed HTTPRequest:set_payload
*/ */
void set_payload(const std::string &payload); void set_payload(QByteArray payload);
/** /**
* Sets a header in the request * Sets a header in the request
@ -105,7 +105,7 @@ public:
* @lua@param value string * @lua@param value string
* @exposed HTTPRequest:set_header * @exposed HTTPRequest:set_header
*/ */
void set_header(std::string name, std::string value); void set_header(QByteArray name, QByteArray value);
/** /**
* Executes the HTTP request * Executes the HTTP request