Skip to content

Commit

Permalink
Use new ringo/base16 module for Etag encoding.
Browse files Browse the repository at this point in the history
  • Loading branch information
hns committed May 19, 2011
1 parent bd1ad9c commit cd2a1d7
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions lib/stick/middleware/etag.js
Expand Up @@ -8,6 +8,7 @@
var strings = require('ringo/utils/strings');
var {Headers} = require('ringo/utils/http');
var {ByteString} = require('binary');
var base16 = require('ringo/base16');

/**
* Middleware for conditional HTTP GET request based on
Expand All @@ -24,16 +25,7 @@ exports.middleware = function etag(next, app) {
md.update(part);
});
var b = ByteString.wrap(md.digest());
var buf = [];

for (var i = 0; i < b.length; i++) {
var j = b[i];
if (j < 16) {
buf[buf.length] = "0";
}
buf[buf.length] = j.toString(32);
}
return buf.join("");
return base16.encode(b);
}

return function etag(request) {
Expand Down

0 comments on commit cd2a1d7

Please sign in to comment.