Merge pull request #273 from roxma/master

Fix ws read failure when using 16bit payload
This commit is contained in:
Jaeseung Ha 2017-12-25 00:47:30 +09:00 committed by GitHub
commit ca48f5c801
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -191,7 +191,7 @@ namespace crow
{ {
is_reading = false; is_reading = false;
mini_header_ = htons(mini_header_); mini_header_ = ntohs(mini_header_);
#ifdef CROW_ENABLE_DEBUG #ifdef CROW_ENABLE_DEBUG
if (!ec && bytes_transferred != 2) if (!ec && bytes_transferred != 2)
@ -231,9 +231,9 @@ namespace crow
case WebSocketReadState::Len16: case WebSocketReadState::Len16:
{ {
remaining_length_ = 0; remaining_length_ = 0;
uint16_t remaining_length16_ = 0; remaining_length16_ = 0;
boost::asio::async_read(adaptor_.socket(), boost::asio::buffer(&remaining_length16_, 2), boost::asio::async_read(adaptor_.socket(), boost::asio::buffer(&remaining_length16_, 2),
[this,&remaining_length16_](const boost::system::error_code& ec, std::size_t [this](const boost::system::error_code& ec, std::size_t
#ifdef CROW_ENABLE_DEBUG #ifdef CROW_ENABLE_DEBUG
bytes_transferred bytes_transferred
#endif #endif
@ -502,6 +502,7 @@ namespace crow
std::string message_; std::string message_;
std::string fragment_; std::string fragment_;
WebSocketReadState state_{WebSocketReadState::MiniHeader}; WebSocketReadState state_{WebSocketReadState::MiniHeader};
uint16_t remaining_length16_{0};
uint64_t remaining_length_{0}; uint64_t remaining_length_{0};
bool close_connection_{false}; bool close_connection_{false};
bool is_reading{false}; bool is_reading{false};