DumpResponse is intended for debugging output, so it’s important for it to surface the chunked encoding. If you want to automatically dechunk, you can use higher level APIs - NewChunkedReader() handles dechunking, and is used internally by transport.
-eli > On Sep 13, 2024, at 9:37 AM, Peter Galbavy <pe...@wonderland.org> wrote: > > Makes sense and good to know, but for diag output is there any way to turn it > off? > > On Friday 13 September 2024 at 14:25:19 UTC+1 Eli Lindsey wrote: >> Those are sizes from chunked encoding. >> >> -eli >> >>> On Sep 13, 2024, at 9:10 AM, Peter Galbavy <pe...@wonderland.org <>> wrote: >>> >>> I am trying to add some low level tracing to a client app to validate the >>> responses coming from a SaaS platform. >> >>> >>> When I use either http's resp.Write(os.Stderr) or >>> httputil.DumpResponse(resp, true) I see a hex content length immediately >>> before the body and a literal "0" on a line after, >>> >>> i.e. using a local copy of the doc example for DumpResponse() but with a >>> real URL and outputting "string(dump)" instead of quotes bytes) to a local >>> server I get (HTML between open/close removed for brevity): >>> >>> --- >>> HTTP/1.1 200 OK >>> Transfer-Encoding: chunked >>> Connection: keep-alive >>> Content-Type: text/html >>> Date: Fri, 13 Sep 2024 13:05:33 GMT >>> Etag: W/"62136b7a-d2" >>> Last-Modified: Mon, 21 Feb 2022 10:37:46 GMT >>> Server: nginx/1.27.0 >>> >>> d2 >>> <!DOCTYPE HTML> >>> <html> >>> ... >>> </html> >>> >>> 0 >>> --- >>> >>> The "d2" is the content length and the "0" is extra. Compared against >>> Postman and curl on the command line, to be sure. >>> >>> Is this expected by undocumented or have I missed something please? >>> >> >>> -- >>> 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...@googlegroups.com <>. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/golang-nuts/07d82e3f-5f14-40da-8856-602c1784e986n%40googlegroups.com >>> >>> <https://groups.google.com/d/msgid/golang-nuts/07d82e3f-5f14-40da-8856-602c1784e986n%40googlegroups.com?utm_medium=email&utm_source=footer>. > > > -- > 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 > <mailto:golang-nuts+unsubscr...@googlegroups.com>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/30b85162-38b5-47a4-8d1a-432ef3d0ea34n%40googlegroups.com > > <https://groups.google.com/d/msgid/golang-nuts/30b85162-38b5-47a4-8d1a-432ef3d0ea34n%40googlegroups.com?utm_medium=email&utm_source=footer>. -- 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/4213A70E-B528-413A-9DE7-F0DABE28113A%40siliconsprawl.com.