Compare commits

...

2 Commits

Author SHA1 Message Date
55ef797f68 Try to not escape HTML in timeline response 2018-07-28 13:42:32 +02:00
67fd816e3f Fix memory leak
Close resp.Body in the main Fetch function. When the resp.Body is not
closed, it will keep all HTTP responses in memory and that amount will
grow, quite fast.
2018-07-28 10:07:07 +02:00
2 changed files with 2 additions and 0 deletions

View File

@ -510,6 +510,7 @@ func Fetch2(fetchURL string) (*http.Response, error) {
if err != nil {
return nil, fmt.Errorf("error while fetching %s: %s", u, err)
}
defer resp.Body.Close()
var b bytes.Buffer
resp.Write(&b)

View File

@ -72,6 +72,7 @@ func (h *microsubHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
jw := json.NewEncoder(w)
w.Header().Add("Content-Type", "application/json")
jw.SetIndent("", " ")
jw.SetEscapeHTML(false)
err = jw.Encode(timeline)
if err != nil {
http.Error(w, err.Error(), 500)