Skip to content
Snippets Groups Projects
Commit fbe3b5d7 authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Fix handling of short send()s

For some reason, I thought socket.send() did this, but apparently
not.  Fixes issue transferring large messages.

Also, add support for the useless NAMESPACE command.
parent d1f89436
No related branches found
No related tags found
No related merge requests found
...@@ -184,19 +184,31 @@ function debug_log(line, rx) ...@@ -184,19 +184,31 @@ function debug_log(line, rx)
/* Socket I/O */ /* Socket I/O */
/**************/ /**************/
function full_send(sock, str)
{
var sent = 0;
var sret;
do {
sret = sock.send(str.substr(sent));
if (sret == undefined)
break;
sent += sret;
} while(sent < str.length);
}
function tagged(tag, msg, desc) function tagged(tag, msg, desc)
{ {
client.socket.send(tag+" "+msg+" "+desc+"\r\n"); full_send(client.socket, tag+" "+msg+" "+desc+"\r\n");
debug_log("Send: "+tag+" "+msg+" "+desc, false); debug_log("Send: "+tag+" "+msg+" "+desc, false);
} }
function untagged(msg) function untagged(msg)
{ {
client.socket.send("* "+msg+"\r\n"); full_send(client.socket, "* "+msg+"\r\n");
debug_log("Send: * "+msg.length+": "+msg, false); debug_log("Send: * "+msg.length+": "+msg, false);
} }
/*************************************************************/ /*************************************************************/
/* Fetch response generation... this is the tricky bit. :-) */ /* Fetch response generation... this is the tricky bit. :-) */
/*************************************************************/ /*************************************************************/
...@@ -1788,6 +1800,18 @@ var authenticated_command_handlers = { ...@@ -1788,6 +1800,18 @@ var authenticated_command_handlers = {
tagged(tag, "NO", "No appending yet... sorry."); tagged(tag, "NO", "No appending yet... sorry.");
}, },
}, },
NAMESPACE:{
arguments: 0,
handler:function(args) {
var tag=args[0];
if (user.security.restrictions & UFLAG_G)
untagged('NAMESPACE NIL NIL (("" ' + encode_string(sepchar) + '))');
else
untagged('NAMESPACE (("" ' + encode_string(sepchar) + ')) NIL NIL');
tagged(tag, "OK", "Maybe this will get separators to work.");
},
},
}; };
function do_store(seq, uid, item, data) function do_store(seq, uid, item, data)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment