Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 15, 2026

HTTP 304 (Not Modified) responses were including a JSON body and potentially Transfer-Encoding/Content-Encoding headers, violating RFC 7232 Section 4.1. This caused browsers to close connections, resulting in SSL errors when the systemd-journal plugin returned 304 responses.

Changes

src/libnetdata/json/json-c-parser-inline.c

  • Skip JSON body creation for 304 responses in rrd_call_function_error()

src/web/server/web_client.c

  • Exclude Transfer-Encoding and Content-Encoding headers for 304 responses
  • Always send Content-Length: 0 for 304 responses
  • Preserve keep-alive instead of disabling it

Before

HTTP/1.1 304 Not Modified
Content-Type: application/json
Content-Length: 52

{"status": 304, "error_message": "not modified"}

After

HTTP/1.1 304 Not Modified
Content-Length: 0

Per RFC 7232, 304 responses MUST NOT contain a message body and MUST NOT include entity headers like Transfer-Encoding or Content-Encoding.

Original prompt

This section details on the original issue you should resolve

<issue_title>[Bug]: HTTP response NOT_MOFILED closes the browser socket</issue_title>
<issue_description>### Bug description

systemd-journal plugin sends HTTP response code 304 (Not Modified).

But this response does not have a payload, which makes the web browser close the socket, making netdata log

Jul 13 02:14:24 lab-nd-dev-parent3-ssl netdata[2929970]: SSL: SSL_read() on socket local [[10.10.11.3]:19999] <-> remote [[10.20.4.205]:48050], returned error 1 (SSL_ERROR_SSL): error:00000001:lib(0)::reason(1)
Jul 13 02:14:25 lab-nd-dev-parent3-ssl netdata[2929970]: SSL: SSL_accept() on socket local [[10.10.11.3]:19999] <-> remote [[10.20.4.205]:45720], returned error 1 (SSL_ERROR_SSL): error:00000001:lib(0)::reason(1)
Jul 13 02:14:25 lab-nd-dev-parent3-ssl netdata[2929970]: SSL: on socket local [[10.10.11.3]:19999] <-> remote [[10.20.4.205]:45720], attempt to read on a failed connection

Expected behavior

The response from netdata should have a payload to prevent the socket from closing.

Steps to reproduce

  1. setup netdata with SSL on port 19999
  2. open the Logs tab
  3. hit play
  4. check the netdata logs

Installation method

kickstart.sh

System info

all of them

Netdata build info

all of them

Additional info

No response</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.


Summary by cubic

Prevents browser sockets from closing in the Logs view by making 304 Not Modified responses RFC-compliant, so connections stay open when there are no new logs. Fixes #18138.

  • Bug Fixes
    • Do not include a JSON body for 304 responses.
    • Do not send Transfer-Encoding or Content-Encoding for 304.
    • Always send Content-Length: 0 for 304.

Written for commit 83713a3. Summary will update on new commits.

Copilot AI and others added 3 commits January 15, 2026 13:39
- Modified rrd_call_function_error to not add JSON body for 304 responses
- Updated web_client_build_http_header to send Content-Length: 0 for 304 responses
- This prevents socket closure and SSL errors when systemd-journal returns 304

Co-authored-by: ilyam8 <22274335+ilyam8@users.noreply.github.com>
- Ensure 304 responses never use chunked transfer or gzip encoding
- Always send Content-Length: 0 for 304 responses
- Addresses code review feedback

Co-authored-by: ilyam8 <22274335+ilyam8@users.noreply.github.com>
- Add RFC 7232 Section 4.1 reference to comments
- Clarify Content-Length handling logic with better comments

Co-authored-by: ilyam8 <22274335+ilyam8@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix HTTP response 304 closing browser socket Fix HTTP 304 responses to comply with RFC 7232 Jan 15, 2026
Copilot AI requested a review from ilyam8 January 15, 2026 13:46
@ilyam8
Copy link
Member

ilyam8 commented Jan 15, 2026

@cubic-dev-ai review this PR

@cubic-dev-ai
Copy link
Contributor

cubic-dev-ai bot commented Jan 15, 2026

@cubic-dev-ai review this PR

@ilyam8 I have started the AI code review. It will take a few minutes to complete.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 2 files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: HTTP response NOT_MOFILED closes the browser socket

2 participants