diff --git a/server/cache_sqlite.go b/server/cache_sqlite.go index 89e932e8..e1c18f6c 100644 --- a/server/cache_sqlite.go +++ b/server/cache_sqlite.go @@ -68,6 +68,9 @@ func (c *sqliteCache) Messages(topic string, since sinceTime) ([]*message, error if err := rows.Scan(&id, ×tamp, &msg); err != nil { return nil, err } + if msg == "" { + msg = " " // Hack: never return empty messages; this should not happen + } messages = append(messages, &message{ ID: id, Time: timestamp, diff --git a/server/server.go b/server/server.go index 07b9973c..3ccc86a9 100644 --- a/server/server.go +++ b/server/server.go @@ -243,6 +243,9 @@ func (s *Server) handlePublish(w http.ResponseWriter, r *http.Request, v *visito return err } m := newDefaultMessage(t.id, string(b)) + if m.Message == "" { + return errHTTPBadRequest + } if err := t.Publish(m); err != nil { return err }