a:5:{s:9:"#provides";s:18:"dojox.io.httpParse";s:9:"#resource";s:15:"io/httpParse.js";s:18:"dojox.io.httpParse";a:5:{s:4:"type";s:8:"Function";s:10:"parameters";a:3:{s:10:"httpStream";a:2:{s:4:"type";s:6:"String";s:7:"summary";s:20:"HTTP stream to parse";}s:10:"topHeaders";a:3:{s:8:"optional";b:1;s:4:"type";s:6:"String";s:7:"summary";s:79:"Extra header information to add to each HTTP request (kind of HTTP inheritance)";}s:7:"partial";a:3:{s:8:"optional";b:1;s:4:"type";s:7:"Boolean";s:7:"summary";s:339:"A true value indicates that the stream may not be finished, it may end arbitrarily in mid stream. The last XHR object will have a special property _lastIndex that indicates the how far along the httpStream could be successfully parsed into HTTP messages. return: Returns an array of XHR-like object for reading the headers for each message";}}s:6:"source";s:2331:" var xhrs=[]; var streamLength = httpStream.length; do{ var headers = {}; var httpParts = httpStream.match(/(\n*[^\n]+)/); if(!httpParts){ return null; } httpStream = httpStream.substring(httpParts[0].length+1); httpParts = httpParts[1]; var headerParts = httpStream.match(/([^\n]+\n)*/)[0]; httpStream = httpStream.substring(headerParts.length); var headerFollowingChar = httpStream.substring(0,1); httpStream = httpStream.substring(1); headerParts = (topHeaders || "") + headerParts; var headerStr = headerParts; headerParts = headerParts.match(/[^:\n]+:[^\n]+\n/g); // parse the containing and contained response headers with the contained taking precedence (by going last) for(var j = 0; j < headerParts.length; j++){ var colonIndex = headerParts[j].indexOf(':'); headers[headerParts[j].substring(0,colonIndex)] = headerParts[j].substring(colonIndex+1).replace(/(^[ \r\n]*)|([ \r\n]*)$/g,''); // trim } httpParts = httpParts.split(' '); var xhr = { // make it look like an xhr object, at least for the response part of the API status : parseInt(httpParts[1],10), statusText : httpParts[2], readyState : 3, // leave it at 3 until we get a full body getAllResponseHeaders : function(){ return headerStr; }, getResponseHeader : function(name){ return headers[name]; } }; var contentLength = headers['Content-Length']; var content; if(contentLength){ if(contentLength <= httpStream.length){ content = httpStream.substring(0,contentLength); }else{ return xhrs; // the content is not finished } }else if((content = httpStream.match(/(.*)HTTP\/\d\.\d \d\d\d[\w\s]*\n/))){ // assign content // if we spot another HTTP message coming up, we will just assign all the in between text to the content content = content[0]; }else if(!partial || headerFollowingChar == '\n'){ // if we have to finish content = httpStream; }else{ return xhrs; } xhrs.push(xhr); // add it to the list, since it is a full HTTP message httpStream = httpStream.substring(content.length); // move along the stream xhr.responseText = content; xhr.readyState = 4; xhr._lastIndex = streamLength - httpStream.length; // need to pick up from where we left on streaming connections }while(httpStream); return xhrs;";s:7:"summary";s:36:"Parses an HTTP stream for a message.";s:7:"returns";s:27:"the content is not finished";}s:8:"dojox.io";a:2:{s:4:"type";s:6:"Object";s:7:"summary";s:0:"";}s:5:"dojox";a:2:{s:4:"type";s:6:"Object";s:7:"summary";s:0:"";}}