惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Engineering at Meta
Engineering at Meta
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
人人都是产品经理
人人都是产品经理
Project Zero
Project Zero
T
Tailwind CSS Blog
Jina AI
Jina AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
小众软件
小众软件
L
LINUX DO - 热门话题
Spread Privacy
Spread Privacy
大猫的无限游戏
大猫的无限游戏
Google DeepMind News
Google DeepMind News
The Hacker News
The Hacker News
C
Cisco Blogs
T
The Exploit Database - CXSecurity.com
C
CXSECURITY Database RSS Feed - CXSecurity.com
Scott Helme
Scott Helme
Security Archives - TechRepublic
Security Archives - TechRepublic
H
Heimdal Security Blog
博客园 - 【当耐特】
W
WeLiveSecurity
J
Java Code Geeks
Latest news
Latest news
酷 壳 – CoolShell
酷 壳 – CoolShell
T
Troy Hunt's Blog
博客园 - Franky
月光博客
月光博客
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
PCI Perspectives
PCI Perspectives
博客园_首页
C
CERT Recently Published Vulnerability Notes
P
Proofpoint News Feed
P
Palo Alto Networks Blog
I
InfoQ
Security Latest
Security Latest
Hacker News: Ask HN
Hacker News: Ask HN
Microsoft Azure Blog
Microsoft Azure Blog
M
MIT News - Artificial intelligence
Help Net Security
Help Net Security
F
Full Disclosure
Cyberwarzone
Cyberwarzone
D
DataBreaches.Net
The Cloudflare Blog
S
Securelist
美团技术团队
C
Cybersecurity and Infrastructure Security Agency CISA
AI
AI
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events

博客园 - ifdef

wxRichTextCtrl移动到最后一行显示 MFC的DLL工程加载异常的问题 VC FormView 上的CEdit不能响应复制粘贴按键(CTRL+C和CTRL+V)的问题 win10环境安装vs2015的问题:缺少JavaScript_ProjectSystem.msi和JavaScript_LanguageService.msi等等 记录:LINUX下,编译一个调用了OPENCV库的程序出错的解决方法 解决:小米11导入其他手机的VCF文件后,电话簿不完整的问题 linux下查看usb设备的端点、VID/PID等信息 VS2010编译静态链接MFC的OCX遇到的问题:nafxcwd.lib(dllmodul.obj) : error LNK2005: _DllMain@12 已经在 LIBCMTD.lib(dllmain.obj) 中定义 linux C++中宏定义的问题:error: unable to find string literal operator ‘operator""fmt’ with ‘const char [4]’, ‘long unsigned int’ arguments 新装vs2010的问题:fatal error LNK1123: 转换到 COFF 期间失败: 文件无效或损坏 windows下删除虚拟串口的方法,以及解决串口使用中,无法变更设备串口号的问题 error C4996: 'stricmp': The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name: _stricmp. 给linux shell 添加ll命令支持 编译WDF驱动项目时,缺少WDKConversion\PreConfiguration.props文件的问题 - ifdef - 博客园 error C3867: “ClassA::OnFuncA”: 函数调用缺少参数列表;请使用“&ClassA::OnFuncA”创建指向成员的指针 VS2010的_vscprintf函数在BCB6下的替代方法vsnprintf LINUX下USB转串口编程中的一点心得 逐个删除网页输入框的下拉提示 升级win10 1903版后,vmware打开虚拟机黑屏的解决办法
调用libhv的HTTP客户端给服务器发送图片失败或图片不完整的问题
ifdef · 2022-03-29 · via 博客园 - ifdef

注意1:本文基于libhv-v1.2.5测试,其他版本不一定适用!

注意2:HTTP服务器可以用HFS工具模拟!

最近在测试hv的http上传图片功能,发现向HTTP服务器发送图片时,服务端总是收不到数据或者收不全,在官方QQ群反馈也没有响应。

经过对libhv代码调试跟踪找到了如下办法可以解决问题:

1. http/http_content.cpp的107行,增加一段代码

2. http/client/http_client.cpp,将++fail_cnt == 1的判断修改为 ++fail_cnt == 0,即忽略此判断,避免出现重复提交图片的情况

实际测试程序的代码如下

 1 #include <stdio.h>
 2 #include <stdlib.h>
 3 #include "http_client.h"
 4 
 5 int main(int argc, char* argv[])
 6 {
 7   HttpResponse resp;
 8   HttpRequest req;
 9   req.method = HTTP_POST;
10   req.url = "http://192.168.1.200/upload";
11   req.headers["Connection"] = "keep-alive";
12   //req.headers["Content-Type"] = "application/octet-stream";
13   req.timeout = 20;
14   FormData form;
15   form.filename = std::string("/tmp/up.jpg");
16   req.form["file"] = form;
17   //int rc = http_client_send(http, &req, &resp);
18   //http_client_t* http = http_client_new();
19   hv::HttpClient hc;
20   int r = hc.send(&req, &resp);
21   printf("http result = %d\n\n", r);
22   return 0;
23 }