Navigation Menu

Skip to content

Commit

Permalink
[api] Attempt naive framing via search for fist occurance of \r\n\r\n
Browse files Browse the repository at this point in the history
  • Loading branch information
indexzero committed Feb 12, 2012
1 parent 075c73f commit c85778f
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions lib/balancing-proxy.js
Expand Up @@ -250,18 +250,23 @@ exports.createServer = function () {
//self.emit('clientError', e);
});

var state = 'no-headers'

socket.ondata = function(d, start, end) {
console.log(d.toString());
var ret = parser.execute(d, start, end - start);
console.dir(ret);
console.dir(d.slice(0, ret).toString());
console.dir(start);
console.dir(end);
if (ret instanceof Error) {
debug('parse error');
socket.destroy(ret);
return;
}
if (state === 'no-headers') {
var ret = parser.execute(d, start, end - start);
var CLRFCLRF = '\r\n\r\n';
var boundary = d.toString().indexOf(CLRFCLRF);
console.dir(d.slice(0, boundary + CLRFCLRF.length).toString());
console.dir(d.slice(boundary + CLRFCLRF.length).toString())

if (ret instanceof Error) {
debug('parse error');
socket.destroy(ret);
return;
}
}


// else if (parser.incoming && parser.incoming.upgrade) {
// var bytesParsed = ret;
Expand Down

0 comments on commit c85778f

Please sign in to comment.