diff --git a/go.mod b/go.mod index 8dbaa86..afecf67 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.23.0 require ( github.com/dave/jennifer v1.4.1 - github.com/palantir/conjure-go-runtime/v2 v2.84.0 + github.com/palantir/conjure-go-runtime/v2 v2.86.0 github.com/palantir/godel/v2 v2.121.0 github.com/palantir/pkg/cobracli v1.2.0 github.com/palantir/pkg/refreshable v1.5.0 diff --git a/go.sum b/go.sum index 9fa142b..57bfc69 100644 --- a/go.sum +++ b/go.sum @@ -55,8 +55,8 @@ github.com/nwaples/rardecode v1.1.0 h1:vSxaY8vQhOcVr4mm5e8XllHWTiM4JF507A0Katqw7 github.com/nwaples/rardecode v1.1.0/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWkRpHbbfGS0= github.com/openzipkin/zipkin-go v0.2.2 h1:nY8Hti+WKaP0cRsSeQ026wU03QsM762XBeCXBb9NAWI= github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= -github.com/palantir/conjure-go-runtime/v2 v2.84.0 h1:m7lI4wylGO7dvZmufeIUQ/8yO8blZvwChk4Z+oHxOKU= -github.com/palantir/conjure-go-runtime/v2 v2.84.0/go.mod h1:66/CTCvFVD/FhpxRPG0uluTpF97nE2PTwbYT3lvU9ZE= +github.com/palantir/conjure-go-runtime/v2 v2.86.0 h1:q/176kxQAbk+4Vmf0JAziHSnpVWKFFRKqEtJ8YjFGto= +github.com/palantir/conjure-go-runtime/v2 v2.86.0/go.mod h1:66/CTCvFVD/FhpxRPG0uluTpF97nE2PTwbYT3lvU9ZE= github.com/palantir/go-metrics v1.1.1 h1:YL/UmptBjrC6iSCTVr7vfuIcjL0M359Da3/gBGNny10= github.com/palantir/go-metrics v1.1.1/go.mod h1:fRkuipBnsI4nD8Vd9UNcrUJvD8Y0wOJMSbicygcBrGs= github.com/palantir/godel/v2 v2.121.0 h1:K8hLahXf+bioleaXz1Z5veOR5XwOcYtHnpSJc8f0RqU= diff --git a/vendor/github.com/palantir/conjure-go-runtime/v2/conjure-go-client/httpclient/body_types.go b/vendor/github.com/palantir/conjure-go-runtime/v2/conjure-go-client/httpclient/body_types.go index a440967..992e970 100644 --- a/vendor/github.com/palantir/conjure-go-runtime/v2/conjure-go-client/httpclient/body_types.go +++ b/vendor/github.com/palantir/conjure-go-runtime/v2/conjure-go-client/httpclient/body_types.go @@ -36,8 +36,17 @@ type RequestBody interface { // fields of the provided *http.Request to the values returned by the function. type requestBodyFunc func() (length int64, body io.ReadCloser, getBody func() (io.ReadCloser, error), err error) -func (f requestBodyFunc) setRequestBody(req *http.Request) (err error) { - req.ContentLength, req.Body, req.GetBody, err = f() +func (f requestBodyFunc) setRequestBody(req *http.Request) error { + contentLength, body, getBody, err := f() + if err != nil { + return err + } + if body == nil { + body = http.NoBody + contentLength = 0 + getBody = nil + } + req.ContentLength, req.Body, req.GetBody = contentLength, body, getBody return err } @@ -188,3 +197,15 @@ func RequestBodyEncoderObjectBuffer(input any, encoder codecs.Encoder, buffer *b return int64(len(raw)), body, getBody, nil }) } + +// RetrieveReaderFromRequestBody extracts the io.ReadCloser and ContentLength from the RequestBody. +// It is primarily useful for testing. +// This reader does not 'count' as a stream for RequestBodyStreamOnce constraints and +// subsequent requests made using the same RequestBody will use a corrupt already-read body. +func RetrieveReaderFromRequestBody(body RequestBody) (io.ReadCloser, int64, error) { + req := &http.Request{} + if err := body.setRequestBody(req); err != nil { + return nil, 0, err + } + return req.Body, req.ContentLength, nil +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 65aef91..b3290da 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -34,7 +34,7 @@ github.com/mattn/go-runewidth # github.com/nmiyake/pkg/errorstringer v1.1.0 ## explicit; go 1.16 github.com/nmiyake/pkg/errorstringer -# github.com/palantir/conjure-go-runtime/v2 v2.84.0 +# github.com/palantir/conjure-go-runtime/v2 v2.86.0 ## explicit; go 1.22.0 github.com/palantir/conjure-go-runtime/v2/conjure-go-client/httpclient github.com/palantir/conjure-go-runtime/v2/conjure-go-client/httpclient/internal