c++curl返回413请求实体过大,但是post大小远小于max大小
c++ curl returns 413 request entity too large however the post size is much less than max size
我注意到我的一些帖子没有提交,所以我在c++代码中看到了curl的输出,它给出了
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>413 Request Entity Too Large</title>
</head><body>
<h1>Request Entity Too Large</h1>
The requested resource<br />/receiver.php<br />
does not allow request data with POST requests, or the amount of data provided in
the request exceeds the capacity limit.
</body></html>
我在php端测试了允许发布请求的最大大小:
echo ini_get('post_max_size');
我得到了:2000万
然后从c++代码中得到了发送的邮件的大小,如下所示:
void send_request(string url, string field,string data) {
string post_req = field + "=" + data;
CURL *curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, post_req.c_str());
cout << "post size : " << post_req.size() << endl;
curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
帖子只有1059544字节=1M距离2000万还很远
php方面的问题在哪里?还是c++代码?
这个问题既不在C++中,也不在PHP中。
如果PHP前面有一些服务器(通常是用于unix风格服务器的nginx
或apache
,或者用于windows服务器的microsoft的IIS
,尽管也存在其他服务器(,那么问题几乎肯定是该服务器中的配置选项。
不太常见的情况是,也有可能您的服务器有一个生成该响应的防火墙,但更可能是一些服务器软件,如上所述。
同样,不相关,但您的c++代码中有一个错误:数据和字段都应该是url编码的,但显然不是。
相关文章:
- 处理小于cpu数据总线的数据类型.(c++转换为机器代码)
- 如何使用curlpp通过POST方法上传文件和json数据
- 从值小于256的uint16到uint8的Endian安全转换
- 将stl字符串缩小到小于15个字符的容量
- 使用libcurl提交批量url的正确BING Api POST url是什么
- 如何检查两个 std::向量在小于 O(n) 的时间复杂度内是否相等
- 为什么我只能在C++中使用可变长度数组分配小于 10 mb 的内存?
- 如何为字符串生成唯一但一致的 N 位哈希(小于 64 位)?
- 命名空间 pqxx 无法识别 - 将 libpqxx 添加到 Windows 上的 Visual Studio Post
- sizeof(size_t) 可以小于 sizeof(int) 吗?
- C++:如何计算二叉树中其值模块高度小于 2 的节点数?
- unique_ptr < 0 或小于运算符做什么?
- 如何使用boost/beast从HTTP POST请求中解析和提取有效负载?
- 如何使用 curl 将 POST 请求从 python 重写为 C++
- 从简单的 POST 请求中解析异常
- Visual Studio 2017 中的 cpprestapi 问题找不到 POST/GET 常量
- 使用 cpp-httplib 的 POST 请求
- C++模板元编程(版本小于 17,最好是 11)
- 从小于或等于某个 N 的数字列表中最小化或找到 n 个理想的子集和
- c++curl返回413请求实体过大,但是post大小远小于max大小