Skip to content

Commit

Permalink
bugfix for index.js
Browse files Browse the repository at this point in the history
  • Loading branch information
phuslu committed Oct 1, 2014
1 parent 405e512 commit 808ba9e
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions server/php/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,24 @@ function decode_request(data, callback) {
request.body = data.slice(2+headers_length);

zlib.inflateRaw(data.slice(2, 2+headers_length), function(error, buff) {
lines = buff.toString().split("\r\n");
request_line_items = lines.shift().split(" ");
var lines = buff.toString().split("\r\n");
var request_line_items = lines.shift().split(" ");
request.method = request_line_items[0];
request.url = request_line_items[1];
lines.forEach(function(line) {
for (var i = 0; i < lines.length; i++) {
var line = lines[i];
var pos = line.indexOf(':');
if (pos > 0) {
var key = line.substring(0, pos);
var value = line.substring(pos+1);
if (key.indexOf('X-URLFETCH-') == 0) {
request.kwargs[key.substring(11)] = value;
var value = line.substring(pos+1).trim();
if (key.toLowerCase().indexOf('x-urlfetch-') == 0) {
request.kwargs[key.substring(11).toLowerCase()] = value;
} else {
key = key.replace(/\w[^\-]*/g, function(w){return w.charAt(0).toUpperCase() + w.substr(1).toLowerCase();})
request.headers[key] = value;
}
}
});
}
if (request.headers.hasOwnProperty('Content-Encoding')
&& request.headers['Content-Encoding'] == 'deflate') {
zlib.inflateRaw(request.body, function(error, buff) {
Expand Down

0 comments on commit 808ba9e

Please sign in to comment.