Sending 100 Continue with unknown Content-Length

74 views
Skip to first unread message

Marks Polakovs

unread,
Mar 18, 2021, 12:55:37 PM3/18/21
to golang-nuts
Hi all,

I'm writing a server that can receive streaming audio (using the Icecast protocol) over HTTP. The gist of the protocol is:
  1. Client sends a PUT with, among others, a "Expect: 100-continue"
  2. Server validates the request and replies with "HTTP/1.1 100 Continue"
  3. Client streams data
The issue I'm running into is that net/http server replies with a 200 OK instead of a 100 Continue unless either the Content-Length is nonzero or Transfer-Encoding is Chunked - the former makes no sense for a (theoretically) infinite stream, while none of the clients I've tested (broadcast-using-this-tool and ffmpeg) do the latter.

I noted that net/http/server.go checks req.ContentLength != 0 before setting canWriteContinue - would it be worthwhile either removing this check, or setting req.ContentLength to -1 if Expect: 100-continue is set for a POST or PUT? This would better mirror real-world behaviour.

thanks,
Marks
Reply all
Reply to author
Forward
0 new messages