-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HTTP Post Request Implementation #53
Conversation
LNK2019 STILL HERE!!! NOT FIXED...
@@ -80,7 +80,53 @@ namespace utils::http | |||
|
|||
if (curl_easy_perform(curl) == CURLE_OK) | |||
{ | |||
return {std::move(buffer)}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This only exists because of my previous commit.
src/component/io.cpp
Outdated
scripting::script_value http_post(const gsc::function_args& args) | ||
{ | ||
const auto url = args[0].as<std::string>(); | ||
const auto headers = args[1].as<utils::http::headers>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is where linker error is happening mainly. Using utils::http::headers
for some reason causes that error. I've even tried just using std::unordered_map<std::string, std::string>
and it causes the same error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because there is no convertion from script_value to utils::http::headers or any std::unordered_map:
const auto array = args[0].as<scripting::array>();
const auto keys = array.get_keys();
utils::http::headers headers{};
for (const auto& key : keys)
{
const auto value = array[key];
if (!key.is<std::string>() || !value.is<std::string>())
{
continue;
}
const auto key_str = key.as<std::string>();
headers[key_str] = value.as<std::string>();
}
It works POGGERS
Thank you for the help fed. Such an obvious solution and here I was going crazy LOL... |
I have written code to support POST HTTP requests, just like GET HTTP request (httpget).
Function in production will look like this:
httppost(url <string>, data <array/json string>, headers <array>)
This will solve issues #46 and #32 too.