mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-26 12:37:09 +08:00
确保32位系统支持超过4GB文件下载
This commit is contained in:
parent
ba213346bc
commit
dc672b14e3
@ -40,7 +40,7 @@ HttpStringBody::HttpStringBody(string str) {
|
||||
_str = std::move(str);
|
||||
}
|
||||
|
||||
ssize_t HttpStringBody::remainSize() {
|
||||
int64_t HttpStringBody::remainSize() {
|
||||
return _str.size() - _offset;
|
||||
}
|
||||
|
||||
@ -150,7 +150,7 @@ private:
|
||||
std::shared_ptr<char> _map_addr;
|
||||
};
|
||||
|
||||
ssize_t HttpFileBody::remainSize() {
|
||||
int64_t HttpFileBody::remainSize() {
|
||||
return _read_to - _file_offset;
|
||||
}
|
||||
|
||||
@ -205,7 +205,7 @@ HttpMultiFormBody::HttpMultiFormBody(const HttpArgs &args, const string &filePat
|
||||
_totalSize = _bodyPrefix.size() + _bodySuffix.size() + _fileBody->remainSize();
|
||||
}
|
||||
|
||||
ssize_t HttpMultiFormBody::remainSize() {
|
||||
int64_t HttpMultiFormBody::remainSize() {
|
||||
return _totalSize - _offset;
|
||||
}
|
||||
|
||||
@ -270,7 +270,7 @@ HttpBufferBody::HttpBufferBody(Buffer::Ptr buffer) {
|
||||
_buffer = std::move(buffer);
|
||||
}
|
||||
|
||||
ssize_t HttpBufferBody::remainSize() {
|
||||
int64_t HttpBufferBody::remainSize() {
|
||||
return _buffer ? _buffer->size() : 0;
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
/**
|
||||
* 剩余数据大小,如果返回-1, 那么就不设置content-length
|
||||
*/
|
||||
virtual ssize_t remainSize() { return 0;};
|
||||
virtual int64_t remainSize() { return 0;};
|
||||
|
||||
/**
|
||||
* 读取一定字节数,返回大小可能小于size
|
||||
@ -77,7 +77,7 @@ public:
|
||||
HttpStringBody(std::string str);
|
||||
~HttpStringBody() override = default;
|
||||
|
||||
ssize_t remainSize() override;
|
||||
int64_t remainSize() override;
|
||||
toolkit::Buffer::Ptr readData(size_t size) override ;
|
||||
|
||||
private:
|
||||
@ -94,7 +94,7 @@ public:
|
||||
HttpBufferBody(toolkit::Buffer::Ptr buffer);
|
||||
~HttpBufferBody() override = default;
|
||||
|
||||
ssize_t remainSize() override;
|
||||
int64_t remainSize() override;
|
||||
toolkit::Buffer::Ptr readData(size_t size) override;
|
||||
|
||||
private:
|
||||
@ -123,7 +123,7 @@ public:
|
||||
*/
|
||||
void setRange(uint64_t offset, uint64_t max_size);
|
||||
|
||||
ssize_t remainSize() override;
|
||||
int64_t remainSize() override;
|
||||
toolkit::Buffer::Ptr readData(size_t size) override;
|
||||
int sendFile(int fd) override;
|
||||
|
||||
@ -152,7 +152,7 @@ public:
|
||||
*/
|
||||
HttpMultiFormBody(const HttpArgs &args,const std::string &filePath,const std::string &boundary = "0xKhTmLbOuNdArY");
|
||||
virtual ~HttpMultiFormBody(){}
|
||||
ssize_t remainSize() override ;
|
||||
int64_t remainSize() override ;
|
||||
toolkit::Buffer::Ptr readData(size_t size) override;
|
||||
|
||||
public:
|
||||
@ -161,8 +161,8 @@ public:
|
||||
static std::string multiFormContentType(const std::string &boundary);
|
||||
|
||||
private:
|
||||
size_t _offset = 0;
|
||||
size_t _totalSize;
|
||||
uint64_t _offset = 0;
|
||||
int64_t _totalSize;
|
||||
std::string _bodyPrefix;
|
||||
std::string _bodySuffix;
|
||||
HttpFileBody::Ptr _fileBody;
|
||||
|
@ -519,7 +519,7 @@ void HttpSession::sendResponse(int code,
|
||||
GET_CONFIG(uint32_t,keepAliveSec,Http::kKeepAliveSecond);
|
||||
|
||||
//body默认为空
|
||||
ssize_t size = 0;
|
||||
int64_t size = 0;
|
||||
if (body && body->remainSize()) {
|
||||
//有body,获取body大小
|
||||
size = body->remainSize();
|
||||
@ -607,9 +607,7 @@ void HttpSession::sendResponse(int code,
|
||||
|
||||
//发送http body
|
||||
AsyncSenderData::Ptr data = std::make_shared<AsyncSenderData>(shared_from_this(), body, bClose);
|
||||
getSock()->setOnFlush([data]() {
|
||||
return AsyncSender::onSocketFlushed(data);
|
||||
});
|
||||
getSock()->setOnFlush([data]() { return AsyncSender::onSocketFlushed(data); });
|
||||
AsyncSender::onSocketFlushed(data);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user