Hi all,

when using httputil.DumpRequestOut, the output produced does not include a 
"Content-Length" header, instead I see the length encoded as a hex-value. 
Additionally, the output produced ends with a "0" in my case.

Example code (Playground: https://play.golang.org/p/GBm5D8YgjJ):

package main


import (
 "fmt"
 "log"
 "net/http"
 "net/http/httputil"
 "io"
 "text/template"
)

const xml = `<xml>{{.Content}}</xml>`

func main() {
 r, w := io.Pipe()
 defer r.Close()
 go func() {
  defer w.Close()
  template.Must(template.New("xml").Parse(xml)).Execute(w, struct{Content 
string}{"<element>value</element>"})
 }()
 
 req, err := http.NewRequest("POST","https://1.1.1.1/";, r)
 if err != nil {
  log.Fatal(err)
 }
 
 dump, err := httputil.DumpRequestOut(req, true)
 if err != nil {
  log.Fatal(err)
 }
 
 fmt.Printf("%s", string(dump))
}




Produces this output:

POST / HTTP/1.1
Host: 1.1.1.1
User-Agent: Go-http-client/1.1
Transfer-Encoding: chunked
Accept-Encoding: gzip

23
<xml><element>value</element></xml>
0


When using strings.NewReader inside http.NewRequest everything works fine 
(Playground example: https://play.golang.org/p/J8FKrbaycm)


Any thoughts or comments what I should improve?



-- Steffen


-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to