Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions lib/handlers/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ async function handler (req, res, next) {
RDFs.includes(contentType) && !isHtmlResource && !ldp.suppressDataBrowser)

if (useDataBrowser) {
res.set('Content-Type', 'text/html')
res.setHeader('Content-Type', 'text/html')
const defaultDataBrowser = require.resolve('mashlib/dist/databrowser.html')
const dataBrowserPath = ldp.dataBrowserPath === 'default' ? defaultDataBrowser : ldp.dataBrowserPath
debug(' sending data browser file: ' + dataBrowserPath)
Expand All @@ -118,23 +118,25 @@ async function handler (req, res, next) {
let headers = {
'Content-Type': contentType
}

if (contentRange) {
headers = {
...headers,
'Content-Range': contentRange,
'Accept-Ranges': 'bytes',
'Content-Length': chunksize
}
res.statusCode = 206
Copy link
Collaborator

@CxRes CxRes Feb 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be set here on the response because when PREP activates, we need to ensure that the status code is still 206 on the response. This code will mean PREP will always use the default res.statusCode value of 200 when sending a response.

res.status(206)
}

if (prep & isRdf(contentType) && !res.sendEvents({
if (prep && isRdf(contentType) && !res.sendEvents({
config: { prep: prepConfig },
body: stream,
isBodyStream: true,
headers
})) return
res.set(headers)

res.writeHead(res.statusCode, headers) // res.set sneds 'charset'
return stream.pipe(res)
}

Expand Down