mirror of
https://github.com/yhirose/cpp-httplib
synced 2024-11-21 14:29:10 -07:00
Properly implement BufferStream::read
The existing implementation did not advance the buffer at all.
This commit is contained in:
parent
7f749740f7
commit
fcdaa24fc5
1 changed files with 5 additions and 2 deletions
|
@ -387,6 +387,7 @@ public:
|
|||
|
||||
private:
|
||||
std::string buffer;
|
||||
int position = 0;
|
||||
};
|
||||
|
||||
class TaskQueue {
|
||||
|
@ -2750,10 +2751,12 @@ inline std::string SocketStream::get_remote_addr() const {
|
|||
// Buffer stream implementation
|
||||
inline int BufferStream::read(char *ptr, size_t size) {
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
return static_cast<int>(buffer._Copy_s(ptr, size, size));
|
||||
int len_read = static_cast<int>(buffer._Copy_s(ptr, size, size, position));
|
||||
#else
|
||||
return static_cast<int>(buffer.copy(ptr, size));
|
||||
int len_read = static_cast<int>(buffer.copy(ptr, size, position));
|
||||
#endif
|
||||
position += len_read;
|
||||
return len_read;
|
||||
}
|
||||
|
||||
inline int BufferStream::write(const char *ptr, size_t size) {
|
||||
|
|
Loading…
Reference in a new issue