Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix REST Posting File to v1/listen #265

Merged
merged 1 commit into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading