No http.ServeStream() ?

111 views
Skip to first unread message

Liam

unread,
Jul 2, 2020, 2:09:05 PM7/2/20
to golang-nuts
Wondering why there's no http.ServeStream() API to do chunked transfer-encoding (or the http2 equivalent), in addition to the nice features of ServeContent()...

Has it been considered? Does it merit a proposal?

If not, some example code in the docs would be helpful...

Tamás Gulácsi

unread,
Jul 3, 2020, 5:50:57 AM7/3/20
to golang-nuts
Maybe because the current ServeHTTP does the chunked transfer-encoding when Content-Length is not set, and the Writes are more than the predefined buffer length?

Juliusz Chroboczek

unread,
Jul 4, 2020, 5:11:29 PM7/4/20
to golan...@googlegroups.com
>> Wondering why there's no http.ServeStream() API to do chunked
>> transfer-encoding (or the http2 equivalent), in addition to the nice
>> features of ServeContent()...

Uh-huh. It would be nice to be able to use the If-None-Match logic for
unseekable strings.

> Maybe because the current ServeHTTP does the chunked transfer-encoding when
> Content-Length is not set, and the Writes are more than the predefined
> buffer length?

I could be wrong, but I think that the Content-Length is always known in
ServeContent:

size, err := content.Seek(0, io.SeekEnd)
if err != nil {
return 0, errSeeker
}

Reply all
Reply to author
Forward
0 new messages