another test Bug Because the responses are to long

This commit is contained in:
Falko Victor Habel 2024-06-21 10:16:54 +02:00
parent ff4aa0f63e
commit 411d44737e
1 changed files with 2 additions and 2 deletions

View File

@ -43,7 +43,7 @@ func createStreamResponse(fromLanguage, toLanguage, message string) string {
return string(jsonResp) return string(jsonResp)
} }
func streamResponse(w http.ResponseWriter, fromLanguage, toLanguage string, messages <-chan string) { func streamResponse(w http.ResponseWriter, messages <-chan string) {
w.Header().Set("Content-Type", "application/json; charset=utf-8") w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.Header().Set("Cache-Control", "no-cache") w.Header().Set("Cache-Control", "no-cache")
w.Header().Set("Connection", "keep-alive") w.Header().Set("Connection", "keep-alive")
@ -55,7 +55,7 @@ func streamResponse(w http.ResponseWriter, fromLanguage, toLanguage string, mess
} }
for msg := range messages { for msg := range messages {
formattedMessage := createStreamResponse(fromLanguage, toLanguage, msg) formattedMessage := createStreamResponse(msg)
fmt.Fprintf(w, " %s\n\n", formattedMessage) fmt.Fprintf(w, " %s\n\n", formattedMessage)
flusher.Flush() flusher.Flush()
} }