Bug 775287 - Track request count in storage server; r=rnewman

This commit is contained in:
Gregory Szorc 2012-07-20 12:00:39 -07:00
parent 2d338f4adf
commit c727c2d588
2 changed files with 9 additions and 5 deletions

View File

@ -876,11 +876,12 @@ let StorageServerCallback = {
* StorageServerCallback) as input.
*/
function StorageServer(callback) {
this.callback = callback || {__proto__: StorageServerCallback};
this.server = new HttpServer();
this.started = false;
this.users = {};
this._log = Log4Moz.repository.getLogger(STORAGE_HTTP_LOGGER);
this.callback = callback || {__proto__: StorageServerCallback};
this.server = new HttpServer();
this.started = false;
this.users = {};
this.requestCount = 0;
this._log = Log4Moz.repository.getLogger(STORAGE_HTTP_LOGGER);
// Install our own default handler. This allows us to mess around with the
// whole URL space.
@ -1266,6 +1267,7 @@ StorageServer.prototype = {
* TODO: need to use the correct Storage API response codes and errors here.
*/
handleDefault: function handleDefault(handler, req, resp) {
this.requestCount++;
let timestamp = new_timestamp();
try {
this._handleDefault(handler, req, resp, timestamp);

View File

@ -187,10 +187,12 @@ add_test(function test_basic_http() {
server.startSynchronous(PORT);
_("Started on " + server.port);
do_check_eq(server.requestCount, 0);
let req = localRequest("/2.0/storage/crypto/keys");
_("req is " + req);
req.get(function (err) {
do_check_eq(null, err);
do_check_eq(server.requestCount, 1);
server.stop(run_next_test);
});
});