Send backend a CopyFail when no stream is defined to copy from

This commit is contained in:
Sandro Santilli 2013-01-16 12:40:59 +01:00
parent a39e0d7cc9
commit 2fc22de21a
2 changed files with 6 additions and 5 deletions

View File

@ -267,6 +267,11 @@ p.sendCopyFromChunk = function (chunk) {
p.endCopyFrom = function () {
this.stream.write(this.writer.add(emptyBuffer).flush(0x63));
}
p.sendCopyFail = function (msg) {
//this.stream.write(this.writer.add(emptyBuffer).flush(0x66));
this.writer.addCString(msg);
this._send(0x66);
}
//parsing methods
p.setBuffer = function(buffer) {
if(this.lastBuffer) { //we have unfinished biznaz

View File

@ -171,11 +171,7 @@ p.prepare = function(connection) {
};
p.streamData = function (connection) {
if ( this.stream ) this.stream.startStreamingToConnection(connection);
else {
connection.endCopyFrom(); // send an EOF to connection
// TODO: signal the problem somehow
//this.handleError(new Error('No source stream defined'));
}
else connection.sendCopyFail('No source stream defined');
};
p.handleCopyFromChunk = function (chunk) {
if ( this.stream ) this.stream.handleChunk(chunk);