mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2025-01-09 23:47:23 +03:00
querylog: imp code
This commit is contained in:
parent
649454e77b
commit
0b27f048a7
1 changed files with 5 additions and 3 deletions
|
@ -115,13 +115,14 @@ func (l *queryLog) handleQueryLogExport(w http.ResponseWriter, r *http.Request)
|
|||
searchCriteria: searchCriteria,
|
||||
}
|
||||
|
||||
w.Header().Set(httphdr.ContentType, "text/csv")
|
||||
w.Header().Set(httphdr.ContentType, "text/csv; charset=UTF-8; header=present")
|
||||
w.Header().Set(httphdr.ContentDisposition, "attachment;filename=data.csv")
|
||||
|
||||
csvWriter := csv.NewWriter(w)
|
||||
defer func() {
|
||||
if err = csvWriter.Error(); err != nil {
|
||||
aghhttp.Error(r, w, http.StatusInternalServerError, "writing csv")
|
||||
// TODO(a.garipov): Set Trailer X-Error header.
|
||||
log.Error("%s %s %s: %s", r.Method, r.Host, r.URL, "writing csv")
|
||||
}
|
||||
}()
|
||||
|
||||
|
@ -150,7 +151,8 @@ func (l *queryLog) handleQueryLogExport(w http.ResponseWriter, r *http.Request)
|
|||
|
||||
for _, entry := range entries {
|
||||
if err = csvWriter.Write(entry.toCSV()); err != nil {
|
||||
http.Error(w, "writing csv record", http.StatusInternalServerError)
|
||||
// TODO(a.garipov): Set Trailer X-Error header.
|
||||
log.Error("%s %s %s: %s", r.Method, r.Host, r.URL, "writing csv record")
|
||||
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue