define([ "dojo/_base/declare", "./HttpResponse" ], function(declare, HttpResponse) { return declare(HttpResponse, { presenter : null, constructor : function(model, options) { if (options && options.presenter) this.presenter = options.presenter; }, send : function() { console.log("try to present: " + this.content); if (!this.presenter) throw "The presenter isn't specified for the model '" + this.content + "'"; if (this.statusCode != 203 && this.presenter.contentType) this.setHeader("Content-type", this.presenter.contentType); this.inherited(arguments); }, writeEntity : function(serverResponse) { if (this.statusCode == 203) return; serverResponse.write(this.presenter.present(this.content), this.getContentType() ? this.getContentType().parameters.charset : undefined); } }); });