mirror of
https://github.com/axllent/mailpit.git
synced 2025-01-06 00:25:39 +02:00
Ignore http.RsponseWriter errors
This commit is contained in:
parent
f6ae6bbdbb
commit
788e390e01
@ -29,7 +29,7 @@ func apiListMailboxes(w http.ResponseWriter, _ *http.Request) {
|
|||||||
|
|
||||||
bytes, _ := json.Marshal(res)
|
bytes, _ := json.Marshal(res)
|
||||||
w.Header().Add("Content-Type", "application/json")
|
w.Header().Add("Content-Type", "application/json")
|
||||||
w.Write(bytes)
|
_, _ = w.Write(bytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
func apiListMailbox(w http.ResponseWriter, r *http.Request) {
|
func apiListMailbox(w http.ResponseWriter, r *http.Request) {
|
||||||
@ -62,7 +62,7 @@ func apiListMailbox(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
bytes, _ := json.Marshal(res)
|
bytes, _ := json.Marshal(res)
|
||||||
w.Header().Add("Content-Type", "application/json")
|
w.Header().Add("Content-Type", "application/json")
|
||||||
w.Write(bytes)
|
_, _ = w.Write(bytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
func apiSearchMailbox(w http.ResponseWriter, r *http.Request) {
|
func apiSearchMailbox(w http.ResponseWriter, r *http.Request) {
|
||||||
@ -102,7 +102,7 @@ func apiSearchMailbox(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
bytes, _ := json.Marshal(res)
|
bytes, _ := json.Marshal(res)
|
||||||
w.Header().Add("Content-Type", "application/json")
|
w.Header().Add("Content-Type", "application/json")
|
||||||
w.Write(bytes)
|
_, _ = w.Write(bytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open a message
|
// Open a message
|
||||||
@ -120,7 +120,7 @@ func apiOpenMessage(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
bytes, _ := json.Marshal(msg)
|
bytes, _ := json.Marshal(msg)
|
||||||
w.Header().Add("Content-Type", "application/json")
|
w.Header().Add("Content-Type", "application/json")
|
||||||
w.Write(bytes)
|
_, _ = w.Write(bytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Download/view an attachment
|
// Download/view an attachment
|
||||||
@ -143,7 +143,7 @@ func apiDownloadAttachment(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
w.Header().Add("Content-Type", a.ContentType)
|
w.Header().Add("Content-Type", a.ContentType)
|
||||||
w.Header().Set("Content-Disposition", "filename=\""+fileName+"\"")
|
w.Header().Set("Content-Disposition", "filename=\""+fileName+"\"")
|
||||||
w.Write(a.Content)
|
_, _ = w.Write(a.Content)
|
||||||
}
|
}
|
||||||
|
|
||||||
// View the full email source as plain text
|
// View the full email source as plain text
|
||||||
@ -165,7 +165,7 @@ func apiDownloadSource(w http.ResponseWriter, r *http.Request) {
|
|||||||
if dl == "1" {
|
if dl == "1" {
|
||||||
w.Header().Set("Content-Disposition", "attachment; filename=\""+id+".eml\"")
|
w.Header().Set("Content-Disposition", "attachment; filename=\""+id+".eml\"")
|
||||||
}
|
}
|
||||||
w.Write(data)
|
_, _ = w.Write(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete all messages in the mailbox
|
// Delete all messages in the mailbox
|
||||||
@ -181,7 +181,7 @@ func apiDeleteAll(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Add("Content-Type", "text/plain")
|
w.Header().Add("Content-Type", "text/plain")
|
||||||
w.Write([]byte("ok"))
|
_, _ = w.Write([]byte("ok"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete a single message
|
// Delete a single message
|
||||||
@ -198,7 +198,7 @@ func apiDeleteOne(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Add("Content-Type", "text/plain")
|
w.Header().Add("Content-Type", "text/plain")
|
||||||
w.Write([]byte("ok"))
|
_, _ = w.Write([]byte("ok"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mark single message as unread
|
// Mark single message as unread
|
||||||
@ -215,7 +215,7 @@ func apiUnreadOne(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Add("Content-Type", "text/plain")
|
w.Header().Add("Content-Type", "text/plain")
|
||||||
w.Write([]byte("ok"))
|
_, _ = w.Write([]byte("ok"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Websocket to broadcast changes
|
// Websocket to broadcast changes
|
||||||
|
@ -64,7 +64,7 @@ func Listen() {
|
|||||||
func basicAuthResponse(w http.ResponseWriter) {
|
func basicAuthResponse(w http.ResponseWriter) {
|
||||||
w.Header().Set("WWW-Authenticate", `Basic realm="Login"`)
|
w.Header().Set("WWW-Authenticate", `Basic realm="Login"`)
|
||||||
w.WriteHeader(http.StatusUnauthorized)
|
w.WriteHeader(http.StatusUnauthorized)
|
||||||
w.Write([]byte("Unauthorised.\n"))
|
_, _ = w.Write([]byte("Unauthorised.\n"))
|
||||||
}
|
}
|
||||||
|
|
||||||
type gzipResponseWriter struct {
|
type gzipResponseWriter struct {
|
||||||
|
@ -133,5 +133,5 @@ func ServeWs(hub *Hub, w http.ResponseWriter, r *http.Request) {
|
|||||||
func basicAuthResponse(w http.ResponseWriter) {
|
func basicAuthResponse(w http.ResponseWriter) {
|
||||||
w.Header().Set("WWW-Authenticate", `Basic realm="Login"`)
|
w.Header().Set("WWW-Authenticate", `Basic realm="Login"`)
|
||||||
w.WriteHeader(http.StatusUnauthorized)
|
w.WriteHeader(http.StatusUnauthorized)
|
||||||
w.Write([]byte("Unauthorised.\n"))
|
_, _ = w.Write([]byte("Unauthorised.\n"))
|
||||||
}
|
}
|
||||||
|
@ -224,7 +224,7 @@ func Store(mailbox string, b []byte) (string, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
// delete the summary because the data insert failed
|
// delete the summary because the data insert failed
|
||||||
logger.Log().Debugf("[db] error inserting raw message, rolling back")
|
logger.Log().Debugf("[db] error inserting raw message, rolling back")
|
||||||
DeleteOneMessage(mailbox, id)
|
_ = DeleteOneMessage(mailbox, id)
|
||||||
|
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
@ -567,7 +567,7 @@ func DeleteAllMessages(mailbox string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// resets stats for mailbox
|
// resets stats for mailbox
|
||||||
statsRefresh(mailbox)
|
_ = statsRefresh(mailbox)
|
||||||
|
|
||||||
elapsed := time.Since(totalStart)
|
elapsed := time.Since(totalStart)
|
||||||
logger.Log().Infof("Deleted %d messages from %s in %s", totalMessages, mailbox, elapsed)
|
logger.Log().Infof("Deleted %d messages from %s in %s", totalMessages, mailbox, elapsed)
|
||||||
|
@ -84,7 +84,7 @@ func pruneCron() {
|
|||||||
}
|
}
|
||||||
elapsed := time.Since(start)
|
elapsed := time.Since(start)
|
||||||
logger.Log().Infof("Pruned %d messages from %s in %s", limit, m, elapsed)
|
logger.Log().Infof("Pruned %d messages from %s in %s", limit, m, elapsed)
|
||||||
statsRefresh(m)
|
_ = statsRefresh(m)
|
||||||
if !strings.HasSuffix(m, "_data") {
|
if !strings.HasSuffix(m, "_data") {
|
||||||
websockets.Broadcast("prune", nil)
|
websockets.Broadcast("prune", nil)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user