Skip to content

Commit

Permalink
Fix REST Posting File to v1/listen
Browse files Browse the repository at this point in the history
  • Loading branch information
davidvonthenen committed Oct 19, 2024
1 parent 3a0a4d2 commit ce50723
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion examples/speech-to-text/rest/file/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions pkg/client/common/v1/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pkg/client/listen/v1/rest/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 2 additions & 0 deletions pkg/client/rest/v1/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ce50723

Please sign in to comment.