Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
apply remaining CR
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddias committed Sep 8, 2017
1 parent 0913191 commit 45cc11b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
16 changes: 5 additions & 11 deletions src/http/gateway/resources/gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ module.exports = {
if (err) {
return handleGatewayResolverError(err)
}

ipfs.files.cat(data.multihash, (err, stream) => {
if (err) {
log.error(err)
Expand All @@ -91,6 +92,7 @@ module.exports = {
stream._read = () => {}
stream._readableState = {}
}

// response.continue()
let filetypeChecked = false
let stream2 = new Stream.PassThrough({highWaterMark: 1})
Expand All @@ -106,7 +108,8 @@ module.exports = {
log('file type: ', fileSignature)

filetypeChecked = true
const mimeType = mime.lookup((fileSignature) ? fileSignature.ext : null)
const mimeType = mime.lookup(fileSignature ? fileSignature.ext : null)

log('ref ', ref)
log('mime-type ', mimeType)

Expand All @@ -115,18 +118,9 @@ module.exports = {

response
.header('Content-Type', mime.contentType(mimeType))
.header('Access-Control-Allow-Headers', 'X-Stream-Output, X-Chunked-Ouput')
.header('Access-Control-Allow-Methods', 'GET')
.header('Access-Control-Allow-Origin', '*')
.header('Access-Control-Expose-Headers', 'X-Stream-Output, X-Chunked-Ouput')
.send()
} else {
response
.header('Access-Control-Allow-Headers', 'X-Stream-Output, X-Chunked-Ouput')
.header('Access-Control-Allow-Methods', 'GET')
.header('Access-Control-Allow-Origin', '*')
.header('Access-Control-Expose-Headers', 'X-Stream-Output, X-Chunked-Ouput')
.send()
response.send()
}
}

Expand Down
6 changes: 5 additions & 1 deletion test/gateway/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const series = require('async/series')
const API = require('../../src/http')
const loadFixture = require('aegir/fixtures')
const os = require('os')
const path = require('path')

const bigFile = loadFixture(__dirname, '../../node_modules/interface-ipfs-core/test/fixtures/15mb.random', 'ipfs')
const directoryContent = {
Expand All @@ -23,7 +24,10 @@ describe('HTTP Gateway', () => {
let gateway

before((done) => {
const repoPath = os.tmpdir() + '/ipfs-' + Math.random().toString().substring(2, 8) + '-' + Date.now()
const repoPath = path.join(
os.tmpdir(),
'/ipfs-' + Math.random().toString().substring(2, 8) + '-' + Date.now()
)

http.api = new API(repoPath, {
Bootstrap: [],
Expand Down

0 comments on commit 45cc11b

Please sign in to comment.