Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace res.set() #1808

Merged
merged 3 commits into from
Feb 12, 2025
Merged

replace res.set() #1808

merged 3 commits into from
Feb 12, 2025

Conversation

bourgeoa
Copy link
Member

No description provided.

@bourgeoa bourgeoa requested a review from CxRes February 11, 2025 22:33
@bourgeoa bourgeoa linked an issue Feb 11, 2025 that may be closed by this pull request
@CxRes
Copy link
Collaborator

CxRes commented Feb 12, 2025

This is OK for consistency! But I do not understand why it solves the problem.

res.set() is a thin wrapper around res.setHeader() with only minor conveniences, which should not matter because the value (2nd argument to res.set()) is already a string. Similarly, setting res.statusCode and using res.writeHead() are identical.

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.

@CxRes
Copy link
Collaborator

CxRes commented Feb 12, 2025

After further testing, I believe the problem happens because res.set is setting the charset parameter in the Content-Type header field, which is allowed. This is an issue therefore with mashlib which fails to render markdown, presumably because it is doing an exact string match to "text/markdown" and failing that rendering text.

I would revert all changes except L104 and L132, and look for why the render is misunderstanding the media-type.

@bourgeoa
Copy link
Member Author

You are right. Good catch
I checked in the browser network pane and effectively the issue is due to the charset parameter.

I will open an issue in mashlib
Adding back res.statusCode = resStatus to the proposed code should also work

bourgeoa and others added 2 commits February 12, 2025 12:03
Clean up status code for 206 case.
@CxRes
Copy link
Collaborator

CxRes commented Feb 12, 2025

Made some changes, this will work for now.

@bourgeoa bourgeoa merged commit 67fc385 into main Feb 12, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Since PREP text/markdown is rendered as plain text
2 participants