fix: 修复请求体过大处理和冗余代码问题
1. 修复OpenAI TTS接口的请求体过大错误提示,返回正确的状态码和提示信息 2. 删除volcano适配器中无用的空循环扫描代码 3. 修正constants.go的包声明重复空格问题
This commit is contained in:
@@ -132,8 +132,6 @@ func Synthesis(config *dto.ByteDanceTTSConfig, httpClient *HTTPClient, text stri
|
|||||||
if v3Resp.Usage != nil {
|
if v3Resp.Usage != nil {
|
||||||
log.Printf("TTS synthesis completed, usage: %+v", v3Resp.Usage)
|
log.Printf("TTS synthesis completed, usage: %+v", v3Resp.Usage)
|
||||||
}
|
}
|
||||||
for scanner.Scan() {
|
|
||||||
}
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package common
|
package common
|
||||||
|
|
||||||
import "time"
|
import "time"
|
||||||
|
|
||||||
|
|||||||
+5
-4
@@ -58,10 +58,11 @@ func OpenaiTTSHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
r.Body = http.MaxBytesReader(w, r.Body, common.MaxRequestBodySize)
|
r.Body = http.MaxBytesReader(w, r.Body, common.MaxRequestBodySize)
|
||||||
body, err := io.ReadAll(r.Body)
|
body, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if strings.Contains(err.Error(), "request body too large") {
|
if strings.Contains(err.Error(), "request body too large") {
|
||||||
return
|
http.Error(w, fmt.Sprintf("Request body too large (max %d bytes)", common.MaxRequestBodySize), http.StatusRequestEntityTooLarge)
|
||||||
}
|
return
|
||||||
http.Error(w, "Failed to read request body", http.StatusBadRequest)
|
}
|
||||||
|
http.Error(w, "Failed to read request body", http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user