MCPcopy Index your code
hub / github.com/LumaAI-API/Luma-API / HandleRespCookies

Function HandleRespCookies

luma.go:66–97  ·  view source on GitHub ↗
(resp *http.Response)

Source from the content-addressed store, hash-verified

64var mu sync.Mutex
65
66func HandleRespCookies(resp *http.Response) {
67 setCookies := resp.Header.Values("Set-Cookie")
68 if len(setCookies) == 0 {
69 return
70 }
71 mu.Lock()
72 defer mu.Unlock()
73
74 common.Logger.Infow("Luma账号触发返回cookie")
75
76 //get old cookies
77 cookies := make(map[string]string)
78 for _, cookie := range strings.Split(common.COOKIE, ";") {
79 kv := strings.Split(cookie, "=")
80 if len(kv) == 2 {
81 cookies[strings.TrimSpace(kv[0])] = strings.TrimSpace(kv[1])
82 }
83 }
84 for _, cookie := range setCookies {
85 names := strings.Split(cookie, "; ")
86 kv := strings.Split(names[0], "=")
87 if len(kv) == 2 {
88 cookies[strings.TrimSpace(kv[0])] = strings.TrimSpace(kv[1])
89 }
90 }
91 var cookieArr []string
92 for k, v := range cookies {
93 cookieArr = append(cookieArr, k+"="+v)
94 }
95 common.COOKIE = strings.Join(cookieArr, "; ")
96 return
97}
98
99func doGeneration(c *gin.Context) {
100 var genRequest GenRequest

Callers 1

DoRequestFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected