Skip to content

Commit

Permalink
解决沉浸式翻译使用 /v1/translate端点时传入多余cookie导致dl_session错误设置的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
IFLYTEK\yuchen48 committed Oct 24, 2024
1 parent c678e87 commit e3d291e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,13 @@ func main() {
return
}

cookie := c.GetHeader("Cookie")
if cookie != "" {
dlSession = strings.Replace(cookie, "dl_session=", "", -1)
if cookie := c.GetHeader("Cookie"); cookie != "" {
for _, part := range strings.Split(cookie, ";") {
if strings.HasPrefix(part, "dl_session=") {
dlSession = strings.TrimPrefix(part, "dl_session=")
break
}
}
}

if dlSession == "" {
Expand Down

0 comments on commit e3d291e

Please sign in to comment.