@@ -15,7 +15,8 @@ var fs = require('fs')
15
15
, pump = require ( 'sys' ) . pump
16
16
, utils = require ( 'connect' ) . utils
17
17
, parseRange = require ( './utils' ) . parseRange
18
- , mime = utils . mime ;
18
+ , mime = utils . mime
19
+ , res = http . ServerResponse . prototype ;
19
20
20
21
/**
21
22
* Header fields supporting multiple values.
@@ -45,7 +46,7 @@ var multiple = ['Set-Cookie'];
45
46
* @api public
46
47
*/
47
48
48
- http . ServerResponse . prototype . send = function ( body , headers , status ) {
49
+ res . send = function ( body , headers , status ) {
49
50
// Allow status as second arg
50
51
if ( typeof headers === 'number' ) {
51
52
status = headers ,
@@ -129,7 +130,7 @@ http.ServerResponse.prototype.send = function(body, headers, status){
129
130
* @api public
130
131
*/
131
132
132
- http . ServerResponse . prototype . sendfile = function ( path , fn ) {
133
+ res . sendfile = function ( path , fn ) {
133
134
var self = this
134
135
, ranges = self . req . headers . range
135
136
, head = 'HEAD' == self . req . method ;
@@ -202,7 +203,7 @@ http.ServerResponse.prototype.sendfile = function(path, fn){
202
203
* @api public
203
204
*/
204
205
205
- http . ServerResponse . prototype . contentType = function ( type ) {
206
+ res . contentType = function ( type ) {
206
207
if ( ! ~ type . indexOf ( '.' ) ) type = '.' + type ;
207
208
return this . header ( 'Content-Type' , mime . type ( type ) ) ;
208
209
} ;
@@ -215,7 +216,7 @@ http.ServerResponse.prototype.contentType = function(type){
215
216
* @api public
216
217
*/
217
218
218
- http . ServerResponse . prototype . attachment = function ( filename ) {
219
+ res . attachment = function ( filename ) {
219
220
this . header ( 'Content-Disposition' , filename
220
221
? 'attachment; filename="' + path . basename ( filename ) + '"'
221
222
: 'attachment' ) ;
@@ -234,7 +235,7 @@ http.ServerResponse.prototype.attachment = function(filename){
234
235
* @api public
235
236
*/
236
237
237
- http . ServerResponse . prototype . download = function ( path , filename , fn ) {
238
+ res . download = function ( path , filename , fn ) {
238
239
this . attachment ( filename || path ) . sendfile ( path , fn ) ;
239
240
} ;
240
241
@@ -253,7 +254,7 @@ http.ServerResponse.prototype.download = function(path, filename, fn){
253
254
* @api public
254
255
*/
255
256
256
- http . ServerResponse . prototype . header = function ( name , val ) {
257
+ res . header = function ( name , val ) {
257
258
if ( val === undefined ) {
258
259
return this . headers [ name ] ;
259
260
} else {
@@ -270,7 +271,7 @@ http.ServerResponse.prototype.header = function(name, val){
270
271
* @api public
271
272
*/
272
273
273
- http . ServerResponse . prototype . clearCookie = function ( name ) {
274
+ res . clearCookie = function ( name ) {
274
275
this . cookie ( name , '' , { expires : new Date ( 1 ) } ) ;
275
276
} ;
276
277
@@ -288,7 +289,7 @@ http.ServerResponse.prototype.clearCookie = function(name){
288
289
* @api public
289
290
*/
290
291
291
- http . ServerResponse . prototype . cookie = function ( name , val , options ) {
292
+ res . cookie = function ( name , val , options ) {
292
293
var cookie = utils . serializeCookie ( name , val , options ) ;
293
294
this . header ( 'Set-Cookie' , cookie ) ;
294
295
} ;
@@ -334,7 +335,7 @@ http.ServerResponse.prototype.cookie = function(name, val, options){
334
335
* @api public
335
336
*/
336
337
337
- http . ServerResponse . prototype . redirect = function ( url , status ) {
338
+ res . redirect = function ( url , status ) {
338
339
var basePath = this . app . set ( 'home' ) || '/'
339
340
, status = status || 302
340
341
, body ;
@@ -379,7 +380,7 @@ http.ServerResponse.prototype.redirect = function(url, status){
379
380
* @api public
380
381
*/
381
382
382
- http . ServerResponse . prototype . local = function ( name , val ) {
383
+ res . local = function ( name , val ) {
383
384
this . locals = this . locals || { } ;
384
385
return undefined === val
385
386
? this . locals [ name ]
0 commit comments