-
Notifications
You must be signed in to change notification settings - Fork 2.5k
如何用workflow的httptask 发送一个post请求,来用于访问Restful的服务器 #356
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
Comments
WFHttpTask *task = create_http_task(...); |
大佬,能否帮忙写个读取本地文件,放到httptask post请求中的 简单demo |
这个很简单啊,你可以参考一下http_file_server这个示例,无非就是在FileIOTask的callback里,创建一个http POST任务。大概长这样: void http_callback(WFHttpTask *http_task)
{
free(http_task->user_data);
// ...
}
void fileio_callback(WFFileIOTask *task)
{
struct FileIOArgs *args = task->get_args();
close(args->fd);
if (task->get_state() != WFT_STATE_SUCCESS)
{
free(args->buf);
return;
}
WFHttpTask *http_task = WFTaskFactory::create_http_task(..., http_callback);
http_task->get_req()->set_method("POST");
http_task->get_req()->append_output_body_nocopy(args->buf, args->count); /* nocopy */
http_task->user_data = args->buf; /* To free. */
**task << http_task; /* equal to: series_of(task)->push_back(http_task); */
} |
An experiment code: https://github.com/chanchann/workflow_annotation/tree/main/demos/14_restful |
Uh oh!
There was an error while loading. Please reload this page.
如何用workflow的httptask 发送一个post请求,来用于访问Restful的服务器
看例子好像是get方式的请求,暂时在HttpRequest类中没有找到相应的方法
比如用curl命令发一个post请求: curl -X POST http://ip:port/func -F 'file=@"123.jpg"' -F "rotate=true"
The text was updated successfully, but these errors were encountered: