- commit
- c05bbeac4fd6ec39a1775ba3f29a90443fc03b30
- parent
- ded4e29c0330c19b830a486214f44ba4cd5a6f8b
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2020-03-25 06:06
fix sse: send 403 before 200
Diffstat
| M | via.go | 20 | ++++++++++---------- |
1 files changed, 10 insertions, 10 deletions
diff --git a/via.go b/via.go
@@ -141,6 +141,16 @@ func getBlocking(w http.ResponseWriter, r *http.Request) {
141 141 func getSse(w http.ResponseWriter, r *http.Request) {
142 142 key, password := splitPassword(r.URL.Path)
143 143
-1 144 ch := make(chan []byte)
-1 145 allowed := pushChannel(key, password, ch)
-1 146 if !allowed {
-1 147 http.Error(w, "Forbidden", http.StatusForbidden)
-1 148 return
-1 149 }
-1 150 defer popChannel(key, ch)
-1 151
-1 152 ctx := r.Context()
-1 153
144 154 ticker := time.NewTicker(10 * time.Second)
145 155 defer ticker.Stop()
146 156
@@ -154,16 +164,6 @@ func getSse(w http.ResponseWriter, r *http.Request) {
154 164 w.WriteHeader(http.StatusOK)
155 165 flusher.Flush()
156 166
157 -1 ch := make(chan []byte)
158 -1 allowed := pushChannel(key, password, ch)
159 -1 if !allowed {
160 -1 http.Error(w, "Forbidden", http.StatusForbidden)
161 -1 return
162 -1 }
163 -1 defer popChannel(key, ch)
164 -1
165 -1 ctx := r.Context()
166 -1
167 167 for {
168 168 select {
169 169 case <-ctx.Done():