Skip to content

Commit

Permalink
[fix] Do correct capability detection on .dest. Fixes mikeal#12
Browse files Browse the repository at this point in the history
  • Loading branch information
indexzero committed Jan 12, 2012
1 parent 3a060ae commit c33a43c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions main.js
Expand Up @@ -84,9 +84,11 @@ function File (options) {
// Source is an HTTP Server Request
if (self.src && (self.src.method === 'GET' || self.src.method === 'HEAD')) {

self.dest.setHeader('content-type', self.mimetype)
self.dest.setHeader('etag', self.etag)
self.dest.setHeader('last-modified', self.lastmodified)
if (self.dest && self.dest.setHeader) {
self.dest.setHeader('content-type', self.mimetype)
self.dest.setHeader('etag', self.etag)
self.dest.setHeader('last-modified', self.lastmodified)
}

if (self.dest && self.dest.writeHead) {
if (self.src && self.src.headers) {
Expand All @@ -105,7 +107,7 @@ function File (options) {
// Destination is not an HTTP response, GET and HEAD method are not allowed
return
}
if (self.dest || self.src.method !== 'HEAD') {
if (self.dest && self.src.method !== 'HEAD') {
fs.createReadStream(self.path).pipe(self.dest)
}
return
Expand Down

0 comments on commit c33a43c

Please sign in to comment.