Comments (9)
应该是task->get_req()->get_parsed_body() .... 这是request啊,不是response。
from workflow.
你能把client的代码贴完整吗?
from workflow.
是不是你二进制数据的原因?printf打印的是字符串,不能打印二进制吧。我wget里的示例,是用fwrite输出的。
from workflow.
bool BSConnect::uploadLog(BSLDATA data)
{
json jstr;
jstr["businessType"] = data.businessType;
jstr["businessName"] = UrlEncode(data.businessName);
jstr["requestData"] = UrlEncode(data.requestData);
jstr["opResult"] = data.opResult;
jstr["opReason"] = UrlEncode(data.opReason);
jstr["useTime"] = data.useTime;
jstr["requestTime"] = data.requestTime;
std::string res = CreateTask(uploadUri, jstr.dump());
// 结果判断
if(res.empty())
{
return false;
}
// 解析json
json jres;
try
{
jres = json::parse(res);
}
catch(const json::exception& e)
{
return false;
}
if(jres["retCode"] == 1)
{
return true;
}
else
{
return false;
}
}
std::string BSConnect::CreateTask(std::string uri, std::string data)
{
std::string uuu = url+uri;
if(uri == uploadUri)
{
uuu = "http://127.0.0.1:9990";
}
std::string res;
int state;
WFFacilities::WaitGroup wait_group(1);
WFHttpTask *task = WFTaskFactory::create_http_task(uuu, REDIRECT_MAX, RETRY_MAX,
[&res,&state,&wait_group](WFHttpTask *task)
{
state = task->get_state();
auto *resp = task->get_resp();
if (state == WFT_STATE_SUCCESS)
{
const void *body = nullptr;
size_t size = 0;
resp->get_parsed_body(&body, &size);
res = std::string((char *)body, size);
size = 123;
}
wait_group.done();
}
);
task->get_req()->append_output_body(data);
task->start();
wait_group.wait();
return res;
}
传的数据"{"businessName":"SDF_OpenSession","businessType":1,"opReason":"test","opResult":1,"requestData":"%7B%22hDeviceHadnle%22%3A1%7D","requestTime":"2024-04-16 19:15:10","useTime":"35"}"
from workflow.
数据长度也没拿到
from workflow.
server能运行到process,但get_parsed_body()却拿不到你的请求和数据长度?size得到是的多少?
from workflow.
还有一个问题,我用workflow传数据,java后台(也是http协议,没用workflw)能拿到吗?
from workflow.
肯定可以啊,要不然协议有什么用。
from workflow.
好的,谢谢
from workflow.
Related Issues (20)
- 有没有复杂一些的http server例子? HOT 1
- 我看了workflow和wfrest,都写得很优雅,上手很快👍🏻。但是我有个疑问,Web服务器为什么不用go和gin呢,而要用workflow?选择workflow的优势有啥? HOT 2
- websocket并发问题咨询 HOT 2
- 用WFFileIOTask写入字符串到文件里出现乱码 HOT 2
- 在tutorial执行"make"报错"collect2: error: ld returned 1 exit status" HOT 7
- 咨询tutorial-05-http-proxy的reply_callback() HOT 2
- 咨询curl向workflow server上传文件,workflow server如何读取文件内容 HOT 2
- httpServerTask的回调函数中设置响应会回复默认响应 HOT 4
- 关于wait_group的详细用法 HOT 26
- 关于workflow TCP连接获取连接地址以及端口问题 HOT 1
- nossl分支tutorial make报错 HOT 5
- 关于GPL许可证兼容性的疑虑 HOT 1
- 支持PostgreSQL协议的讨论帖 HOT 17
- 关于mysql事务的回滚问题 HOT 3
- workflow充当HTTP网关时数据量太大就收不全 HOT 28
- workflow是否支持RPC协议? HOT 1
- WFNetworkTask http 服务怎样获取 post 请求的数据 HOT 2
- 咨询头文件报错问题 HOT 2
- handler_threads配置的问题 HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from workflow.