Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
reminia committed Nov 29, 2023
1 parent 92399c6 commit 56c63d2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 5 additions & 1 deletion translate-cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ func translate(ask Ask) Answer {
defer resp.Body.Close()

var ans Answer
json.NewDecoder(resp.Body).Decode(&ans)
if !original {
json.NewDecoder(resp.Body).Decode(&ans)
} else {
ans.Reply = dumpRespBody(resp)
}
return ans
}

Expand Down
8 changes: 4 additions & 4 deletions utils.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package main

import (
"fmt"
"io"
"net/http"
)

func debug(desc string, reader io.Reader) {
_bytes, _ := io.ReadAll(reader)
fmt.Println("debug", desc, string(_bytes))
func dumpRespBody(resp *http.Response) string {
bytes, _ := io.ReadAll(resp.Body)
return string(bytes)
}

type String string
Expand Down

0 comments on commit 56c63d2

Please sign in to comment.