ngx-distributed-shm
ngx-distributed-shm copied to clipboard
telnet error
Hi,
When testing SET command with telnet, i get an malformed_request
SET KEY 0 1
1
LEN 1
1
DONE
ERROR malformed_request
In unit test, we don't have the malformed_request, because "\r\n" is not send
getWriter().write("SET region:key 1 10\r\n");
getWriter().write("1234567890");
getWriter().flush();
Maybe there is a way to send the command without carriage return in telnet ?
Otherwhise, this issue can be fixed in two ways
- Setting an expectedMode to FrameMode.END
else if (expectedMode == FrameMode.DATA) {
final String result = currentCommand.executeDataPart(buffer.toString(PROTOCOL_ENCODING));
socket.write(result, PROTOCOL_ENCODING);
expectedMode = FrameMode.END;
parser.delimitedMode(PROTOCOL_DELIMITER);
}
else {
expectedMode = FrameMode.COMMAND;
}
but this will make a breaking change
- Handling empty command in ShmProtocolHandler.handle : if (expectedMode == FrameMode.COMMAND && !buffer.toString(PROTOCOL_ENCODING).isEmpty()) { } but not sure allowing empty command is a good idea