Clients to avoid sending payloads larger than the maximum allowed size
Summary: ^ Reviewed By: passy Differential Revision: D48645400 fbshipit-source-id: ac262296f113298812803c12eccf5a37da1da2b7
This commit is contained in:
committed by
Facebook GitHub Bot
parent
865d551f8e
commit
ecc50f47e8
@@ -343,6 +343,13 @@ class JFlipperWebSocket : public facebook::flipper::FlipperSocket {
|
||||
if (socket_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
// Ensure the payload size is valid before sending.
|
||||
// The maximum allowed size for a message payload is 2^53 - 1. But that is
|
||||
// for the entire message, including any additional metadata.
|
||||
if (message.length() > pow(2, 53) - 1) {
|
||||
throw std::length_error("Payload is too big to send");
|
||||
}
|
||||
|
||||
socket_->send(message);
|
||||
completion();
|
||||
}
|
||||
|
||||
@@ -121,6 +121,14 @@ void FlipperWebSocket::send(
|
||||
if (socket_ == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Ensure the payload size is valid before sending.
|
||||
// The maximum allowed size for a message payload is 2^53 - 1. But that is
|
||||
// for the entire message, including any additional metadata.
|
||||
if (message.length() > pow(2, 53) - 1) {
|
||||
throw std::length_error("Payload is too big to send");
|
||||
}
|
||||
|
||||
NSString* messageObjc = [NSString stringWithUTF8String:message.c_str()];
|
||||
[socket_ send:messageObjc
|
||||
withCompletionHandler:^(NSError*) {
|
||||
|
||||
Reference in New Issue
Block a user