Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

304 Page Not Modified returns content after headers #13

Copy link
Copy link
@eoinsha

Description

@eoinsha
Issue body actions

RFC 2616 for HTTP/1.1 dictates that a 304 Page-Not-Modified should have no body.

... The 304 response MUST NOT contain a message-body, and thus is always terminated by the first empty line after the header fields....

lightnode currently uses the chunked encoding header for all responses, including 304s. This results in a "0\r\n" following the message headers.

The following change to move the chunked header to the else clause resolves the issue for me.

                       //REMOVED headers['transfer-encoding'] = 'chunked'
                        headers['server'] = 'lightnode'

                        if (Date.parse(file.header.mtime) <= Date.parse(req.headers['if-modified-since'])) {
                                resp.writeHead(304, headers)
                                resp.end()
                                return
                        }
                        else {
                                headers['transfer-encoding'] = 'chunked' // ADDED
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.