You are right Flush needs to write the header first, so the additional header lines cannot be added by the server after Flush. The automatic Content-Type might also not be written. A local proxy in front of your server might be a simpler approach to measure full performance.
If the actual processing time of the request is not sufficient for you, you might want to use a proxy in front of the server to measure performance. Am Di., 21. Nov. 2023 um 12:28 Uhr schrieb Mitar <mmi...@gmail.com>: > Hi! > > On Mon, Nov 20, 2023 at 10:51 PM Uli Kunitz <uli.kun...@gmail.com> wrote: > > You could convert the original ResponseWriter to a ResponseController > and call Flush in your middleware before you measure the duration. > Alternatively you can try to convert ResponseWriter to a http.Flusher and > call Flush if the conversion is successful. > > Yes, I was thinking something along those lines. But are there any > side effects by calling Flush after the main handler returns? Like in > Write documentation it says: > > "if the total size of all written data is under a few KB and there are > no Flush calls, the Content-Length header is added automatically." > > "Once the headers have been flushed (...), the request body may be > unavailable." > > My understanding is that after the main handler returns, none of this > matters anymore. But are there any other similar side effects? > > > Mitar > > -- > https://mitar.tnode.com/ > https://twitter.com/mitar_m > https://noc.social/@mitar > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAPibus4%2BH3hKmnA8n-yLJLKYTL%3DJX6oricOSMitayE%2BCpwHGUg%40mail.gmail.com.