Resolve an issue when sending big files (>=2gB) on Windows (#529)

This commit is contained in:
An Tao 2020-08-09 19:20:51 +08:00 committed by GitHub
parent fda2719dd4
commit 960309e615
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 7 deletions

View File

@ -317,8 +317,7 @@ void HttpRequestImpl::appendToBuffer(trantor::MsgBuffer *output) const
auto len = snprintf(buf,
sizeof(buf),
"Content-Length: %lu\r\n",
static_cast<long unsigned int>(content.length() +
content_.length()));
content.length() + content_.length());
output->append(buf, len);
if (contentTypeString_.empty())
{

View File

@ -22,7 +22,9 @@
#include <stdio.h>
#include <sys/stat.h>
#include <trantor/utils/Logger.h>
#ifdef _WIN32
#define stat _stati64
#endif
using namespace trantor;
using namespace drogon;
@ -271,7 +273,7 @@ void HttpResponseImpl::makeHeaderString(trantor::MsgBuffer &buffer)
len = snprintf(buffer.beginWrite(),
buffer.writableBytes(),
"Content-Length: %lu\r\n",
static_cast<unsigned long>(bodyLength));
bodyLength);
}
else
{
@ -283,8 +285,8 @@ void HttpResponseImpl::makeHeaderString(trantor::MsgBuffer &buffer)
}
len = snprintf(buffer.beginWrite(),
buffer.writableBytes(),
"Content-Length: %lu\r\n",
static_cast<unsigned long>(filestat.st_size));
"Content-Length: %lld\r\n",
filestat.st_size);
}
buffer.hasWritten(len);
if (headers_.find("Connection") == headers_.end())

View File

@ -23,6 +23,7 @@
#ifndef _WIN32
#include <sys/file.h>
#else
#define stat _stati64
#define S_ISREG(m) (((m)&0170000) == (0100000))
#define S_ISDIR(m) (((m)&0170000) == (0040000))
#endif

@ -1 +1 @@
Subproject commit 13c659a7e0ae2ae2e96f50f726d77c483b861dd8
Subproject commit 6ed38a0a1e9baef9bf68e7952962d8f9425fa749