3

Is there a way to disable chunked transfer encoding in go without using a content-length?

It's for Server-Sent Events which can't have either.

Timmmm
  • 88,195
  • 71
  • 364
  • 509
  • Don't understand. Why can't it use chunked encoding? – Julian Reschke Jan 14 '16 at 17:38
  • @JulianReschke: SSE *can* use chunked encoding, but you may not want to in some cases: https://tools.ietf.org/html/rfc6202#section-4.3 – JimB Jan 14 '16 at 17:43
  • @JimB thanks for the pointer; I have to admit that I don't understand the warning (unless chunking leads to events being sent delayed, but that would simply a bug in the sending party). – Julian Reschke Jan 14 '16 at 18:10
  • @JulianReschke: As far as I know, the only real issue is that you can't rely on the chunks for application message framing, so in general chunked encoding is fine. – JimB Jan 14 '16 at 18:14
  • Raised issue wrt HTML spec: https://github.com/whatwg/html/issues/515 – Julian Reschke Jan 14 '16 at 18:16

1 Answers1

4

Set the transfer encoding header to identity:

w.Header().Set("Transfer-Encoding", "identity")
Charlie Tumahai
  • 113,709
  • 12
  • 249
  • 242