Project

General

Profile

Actions

Bug #3060

closed

SSE stream being corrupted

Added by fgasper over 3 years ago. Updated over 3 years ago.

Status:
Invalid
Priority:
Low
Category:
-
Target version:
-
ASK QUESTIONS IN Forums:
No

Description

I’m just starting with lighttpd and have noticed that an SSE (Server-Sent Events) stream that I send via a CGI script gets corrupted on its way to the browser.

The output I see from netcat’ing to port 80 to run my CGI is:

5d
data: {"temp":"22.79", "humi":"23.993", "baro":"1003.228", "time":"2021-01-19T23:52:46Z"}

5d
data: {"temp":"22.82", "humi":"24.035", "baro":"1003.219", "time":"2021-01-19T23:53:16Z"}

… and so on. Those “5d” things are what’s new. When I used Apache those weren’t there.

When I strace the lighttpd process I confirm that those seem to be from lighttpd itself:

[pid  9921] read(15<pipe:[57119]>, "data: {\"temp\":\"22.92\", \"humi\":\"24.02\", \"baro\":\"1003.17\", \"time\":\"2021-01-19T23:56:16Z\"}\r\n\r\n", 4095) = 91
[pid  9921] writev(10<TCP:[192.168.86.21:80->192.168.86.23:61930]>, [{iov_base="5b\r\ndata: {\"temp\":\"22.92\", \"humi\":\"24.02\", \"baro\":\"1003.17\", \"time\":\"2021-01-19T23:56:16Z\"}\r\n\r\n\r\n", iov_len=97}], 1) = 97

I note that “5b” is 91 in hex, which correlates to the length of the buffer being sent. So maybe something is errantly prefixing the length in hex onto the string output?

I’m using the lighttpd version that ships with Raspi OS, 1.4.53-4+deb10u1. I’ve got it configured with:

$HTTP["url"] =~ "^/cgi-bin/" {
    server.stream-response-body = 2
}

Actions #1

Updated by gstrauss over 3 years ago

  • Category deleted (core)
  • Status changed from New to Invalid
  • Priority changed from Normal to Low
  • Target version deleted (1.4.x)

There is nothing wrong with lighttpd. The response is using chunked encoding. 5d is the length of the chunk. And you should see a final 0 chunked header after the response body content.

If your client sends an HTTP/1.1 request, it must be prepared to receive an HTTP/1.1 response, which might include Transfer-Encoding: chunked

If your client can not handle Transfer-Encoding: chunked, then it must not send an HTTP/1.1 request; it should send an HTTP/1.0 request.

.

This is the lighttpd issue tracker for lighttpd issues, not for user questions.

I’m just starting with lighttpd

Then you should probably ask questions in the Forums (see tab near top of page) instead of filing bugs which are not bugs. (Hint hint)

Actions

Also available in: Atom