Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[fix] Do correct capability detection on `.dest`. Fixes mikeal/filed#12

  • Loading branch information...
commit c33a43c4101243b5c9d51bcb6689773906f0960f 1 parent 3a060ae
@indexzero indexzero authored
Showing with 6 additions and 4 deletions.
  1. +6 −4 main.js
View
10 main.js
@@ -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) {
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.