Enforce continuous validation

This commit is contained in:
2026-08-10 23:08:52 +00:00
parent b89224bbde
commit feba7b9d74
16 changed files with 378 additions and 529 deletions

View File

@@ -99,7 +99,9 @@ func NewHTTPClient(cfg HTTPClientConfig) (*HTTPClient, error) {
client := cfg.HTTPClient
if client == nil {
client = &http.Client{}
transport := http.DefaultTransport.(*http.Transport).Clone()
transport.ExpectContinueTimeout = 100 * time.Millisecond
client = &http.Client{Transport: transport}
}
maxBytes := cfg.MaxResponseBytes
@@ -198,6 +200,7 @@ func (c *HTTPClient) doTranscribeAttempt(ctx context.Context, audioPath string)
return 0, nil, fmt.Errorf("build whisperx request: %w", err)
}
req.Header.Set("Content-Type", upload.contentType)
req.Header.Set("Expect", "100-continue")
resp, err := c.httpClient.Do(req)
if err != nil {
@@ -211,6 +214,9 @@ func (c *HTTPClient) doTranscribeAttempt(ctx context.Context, audioPath string)
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
_ = upload.Close()
if producerErr := upload.Wait(); producerErr != nil {
return resp.StatusCode, nil, fmt.Errorf("stream whisperx request body: %w", producerErr)
}
if _, err := readWhisperXResponse(resp.Body, c.maxResponseBytes); err != nil {
return resp.StatusCode, nil, fmt.Errorf("read whisperx response body: %w", err)
}
@@ -333,7 +339,6 @@ func (u *multipartUpload) Read(p []byte) (int, error) {
func (u *multipartUpload) Close() error {
u.abort()
<-u.done
return nil
}