Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

allow binary buffer in dynamic get reponses

  • Loading branch information...
commit b62d834bd655f963b2b98c4e132d0e240d6a573b 1 parent 8e4edca
@jairajs89 authored
Showing with 26 additions and 2 deletions.
  1. +1 −1  package.json
  2. +25 −1 zerver.js
View
2  package.json
@@ -2,7 +2,7 @@
"author": "Jairaj Sethi <j@jairaj.org> (http://jairaj.org/)",
"name": "zerver",
"description": "client-integrated webapp server",
- "version": "0.8.6",
+ "version": "0.8.7",
"repository": {
"type": "git",
"url": "git://github.com/jairajs89/zerver.git"
View
26 zerver.js
@@ -1012,6 +1012,7 @@ function getRequest (handler, api) {
api.call(handler, handler.params, callback);
}
catch (err) {
+ console.error(err);
if ( !lock ) {
respond500(handler);
}
@@ -1024,6 +1025,25 @@ function getRequest (handler, api) {
}
lock = true;
+ var isBinary = false,
+ buffer;
+
+ if ( Buffer.isBuffer(status) ) {
+ buffer = status;
+ status = 'buffer';
+ isBinary = true;
+ }
+ else if ( Buffer.isBuffer(headers) ) {
+ buffer = headers;
+ headers = 'buffer';
+ isBinary = true;
+ }
+ else if ( Buffer.isBuffer(data) ) {
+ buffer = data;
+ data = 'buffer';
+ isBinary = true;
+ }
+
switch (typeof status) {
case 'undefined':
data = '';
@@ -1068,7 +1088,11 @@ function getRequest (handler, api) {
return;
}
- finishResponse(handler, status, headers, data, false, true);
+ if (isBinary) {
+ data = buffer;
+ }
+
+ finishResponse(handler, status, headers, data, isBinary, true);
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.