From ce50723373fb579e41754941df910866609db605 Mon Sep 17 00:00:00 2001 From: David vonThenen <12752197+dvonthenen@users.noreply.github.com> Date: Sat, 19 Oct 2024 08:32:11 -0700 Subject: [PATCH] Fix REST Posting File to v1/listen --- examples/speech-to-text/rest/file/main.go | 2 +- pkg/client/common/v1/rest.go | 2 ++ pkg/client/listen/v1/rest/client.go | 2 +- pkg/client/rest/v1/rest.go | 2 ++ 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/examples/speech-to-text/rest/file/main.go b/examples/speech-to-text/rest/file/main.go index 9177bacc..12715a6a 100644 --- a/examples/speech-to-text/rest/file/main.go +++ b/examples/speech-to-text/rest/file/main.go @@ -24,7 +24,7 @@ const ( func main() { // init library client.Init(client.InitLib{ - LogLevel: client.LogLevelTrace, // LogLevelStandard / LogLevelFull / LogLevelTrace + LogLevel: client.LogLevelVerbose, // LogLevelStandard / LogLevelFull / LogLevelTrace / LogLevelVerbose }) // Go context diff --git a/pkg/client/common/v1/rest.go b/pkg/client/common/v1/rest.go index 2d73c57a..21b51c8c 100644 --- a/pkg/client/common/v1/rest.go +++ b/pkg/client/common/v1/rest.go @@ -38,6 +38,8 @@ func NewREST(apiKey string, options *interfaces.ClientOptions) *RESTClient { // SetupRequest prepares and returns a new HTTP request with common headers set. func (c *RESTClient) SetupRequest(ctx context.Context, method, uri string, body io.Reader) (*http.Request, error) { + klog.V(3).Infof("Using SetupRequest from Common Package\n") + req, err := http.NewRequestWithContext(ctx, method, uri, body) if err != nil { klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err) diff --git a/pkg/client/listen/v1/rest/client.go b/pkg/client/listen/v1/rest/client.go index 844b4185..87c367f0 100644 --- a/pkg/client/listen/v1/rest/client.go +++ b/pkg/client/listen/v1/rest/client.go @@ -126,7 +126,7 @@ func (c *Client) DoStream(ctx context.Context, src io.Reader, options *interface // the Common.SetupRequest (c.SetupRequest vs c.RESTClient.SetupRequest) method, sets // additional "typical" headers like content-type, etc. // but we want RESTClient.SetupRequest only provides the basic headers in this caser - req, err := c.RESTClient.SetupRequest(ctx, "POST", uri, src) + req, err := c.RESTClient.Client.SetupRequest(ctx, "POST", uri, src) if err != nil { klog.V(1).Infof("SetupRequest failed. Err: %v\n", err) klog.V(6).Infof("prerecorded.DoStream() LEAVE\n") diff --git a/pkg/client/rest/v1/rest.go b/pkg/client/rest/v1/rest.go index d8c3321b..9914b62a 100644 --- a/pkg/client/rest/v1/rest.go +++ b/pkg/client/rest/v1/rest.go @@ -47,6 +47,8 @@ func New(options *interfaces.ClientOptions) *Client { // SetupRequest prepares and returns a new REST request with common headers set. func (c *Client) SetupRequest(ctx context.Context, method, uri string, body io.Reader) (*http.Request, error) { + klog.V(3).Infof("Using SetupRequest from REST Package\n") + req, err := http.NewRequestWithContext(ctx, method, uri, body) if err != nil { klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err)