var Q = require('q');
var superagent = require('superagent');


function wrap(item) {
  return function() {
    var agent = item.apply(superagent, arguments);

    var agentEnd = agent.end;

    agent.end = function() {
      var doEnd = Q.defer();
      agentEnd.call(agent, function(err, res) {
        if (err) return doEnd.reject(err);
        doEnd.resolve(res);
      });
      return doEnd.promise;
    }

    return agent;
  }
}

var agentQ = wrap(superagent);

agentQ.get = wrap(superagent.get);
agentQ.put = wrap(superagent.put);
agentQ.post = wrap(superagent.post);
agentQ.del = wrap(superagent.del);
agentQ.head = wrap(superagent.head);

module.exports = agentQ;

@@ -242,16 +242,107 @@
 efer();%0A
+      %0A      agent.on('progress', function (e) %7B%0A        doEnd.notify(e);%0A      %7D);%0A      %0A
       ag
@@ -458,24 +458,31 @@
 ;%0A      %7D);%0A
+      %0A
       return

implement progress notification on promise