Skip to content

Commit

Permalink
fix: remove middleware preventing range requests
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan Shaw committed Sep 10, 2024
1 parent 8343890 commit fde04c1
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 18 deletions.
2 changes: 0 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
} from '@web3-storage/gateway-lib/handlers'
import {
withContentClaimsDagula,
withHttpRangeUnsupported,
withVersionHeader,
withCarBlockHandler
} from './middleware.js'
Expand Down Expand Up @@ -45,7 +44,6 @@ export default {
withCarBlockHandler,
withContentClaimsDagula,
withFormatRawHandler,
withHttpRangeUnsupported,
withFormatCarHandler,
withContentDispositionHeader,
withFixedLengthStream
Expand Down
16 changes: 0 additions & 16 deletions src/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,6 @@ import { handleCarBlock } from './handlers/car-block.js'
* @typedef {import('@web3-storage/gateway-lib').UnixfsContext} UnixfsContext
*/

/**
* Validates the request does not contain a HTTP `Range` header.
* Returns 501 Not Implemented in case it has.
* @type {import('@web3-storage/gateway-lib').Middleware<import('@web3-storage/gateway-lib').Context>}
*/
export function withHttpRangeUnsupported (handler) {
return (request, env, ctx) => {
// Range request https://github.com/web3-storage/gateway-lib/issues/12
if (request.headers.get('range')) {
throw new HttpError('Not Implemented', { status: 501 })
}

return handler(request, env, ctx)
}
}

/**
* Middleware that will serve CAR files if a CAR codec is found in the path
* CID. If the CID is not a CAR CID it delegates to the next middleware.
Expand Down

0 comments on commit fde04c1

Please sign in to comment.