*: Bump version of vmware/govmomi

Bumping version to include changes that
better handle TLS errors. Bump nescessary
to prepare for when the version of Go is
bumped to 1.20

Signed-off-by: Madhav Jivrajani <madhav.jiv@gmail.com>
This commit is contained in:
Madhav Jivrajani
2023-01-02 20:56:02 +05:30
parent 45df8f0bb3
commit 8b064fa4be
263 changed files with 32336 additions and 4373 deletions

View File

@@ -21,25 +21,19 @@ import (
"io"
"net/http"
"net/http/httputil"
"strings"
"sync/atomic"
"time"
"github.com/vmware/govmomi/vim25/debug"
)
// teeReader wraps io.TeeReader and patches through the Close() function.
type teeReader struct {
io.Reader
io.Closer
}
func newTeeReader(rc io.ReadCloser, w io.Writer) io.ReadCloser {
return teeReader{
Reader: io.TeeReader(rc, w),
Closer: rc,
var (
// Trace reads an http request or response from rc and writes to w.
// The content type (kind) should be one of "xml" or "json".
Trace = func(rc io.ReadCloser, w io.Writer, kind string) io.ReadCloser {
return debug.NewTeeReader(rc, w)
}
}
)
// debugRoundTrip contains state and logic needed to debug a single round trip.
type debugRoundTrip struct {
@@ -71,50 +65,52 @@ func (d *debugRoundTrip) newFile(suffix string) io.WriteCloser {
}
func (d *debugRoundTrip) ext(h http.Header) string {
const json = "application/json"
ext := "xml"
if strings.Contains(h.Get("Content-Type"), "/json") {
if h.Get("Accept") == json || h.Get("Content-Type") == json {
ext = "json"
}
return ext
}
func (d *debugRoundTrip) debugRequest(req *http.Request) {
func (d *debugRoundTrip) debugRequest(req *http.Request) string {
if d == nil {
return
return ""
}
var wc io.WriteCloser
// Capture headers
wc = d.newFile("req.headers")
var wc io.WriteCloser = d.newFile("req.headers")
b, _ := httputil.DumpRequest(req, false)
wc.Write(b)
wc.Close()
ext := d.ext(req.Header)
// Capture body
wc = d.newFile("req." + d.ext(req.Header))
req.Body = newTeeReader(req.Body, wc)
wc = d.newFile("req." + ext)
if req.Body != nil {
req.Body = Trace(req.Body, wc, ext)
}
// Delay closing until marked done
d.cs = append(d.cs, wc)
return ext
}
func (d *debugRoundTrip) debugResponse(res *http.Response) {
func (d *debugRoundTrip) debugResponse(res *http.Response, ext string) {
if d == nil {
return
}
var wc io.WriteCloser
// Capture headers
wc = d.newFile("res.headers")
var wc io.WriteCloser = d.newFile("res.headers")
b, _ := httputil.DumpResponse(res, false)
wc.Write(b)
wc.Close()
// Capture body
wc = d.newFile("res." + d.ext(res.Header))
res.Body = newTeeReader(res.Body, wc)
wc = d.newFile("res." + ext)
res.Body = Trace(res.Body, wc, ext)
// Delay closing until marked done
d.cs = append(d.cs, wc)