(w http.ResponseWriter, r *http.Request, path string, no404 bool)
| 217 | } |
| 218 | |
| 219 | func handleLocalStreamFile(w http.ResponseWriter, r *http.Request, path string, no404 bool) { |
| 220 | http.NewResponseController(w).SetWriteDeadline(time.Time{}) |
| 221 | if no404 { |
| 222 | log.Printf("streaming file w/no404: %q\n", path) |
| 223 | // use the custom response writer |
| 224 | rw := ¬FoundBlockingResponseWriter{w: w, headers: http.Header{}} |
| 225 | |
| 226 | // Serve the file using http.ServeFile |
| 227 | path, err := wavebase.ExpandHomeDir(path) |
| 228 | if err == nil { |
| 229 | http.ServeFile(rw, r, filepath.Clean(path)) |
| 230 | // if the file was not found, serve the transparent GIF |
| 231 | log.Printf("got streamfile status: %d\n", rw.status) |
| 232 | if rw.status == http.StatusNotFound { |
| 233 | serveTransparentGIF(w) |
| 234 | } |
| 235 | } else { |
| 236 | serveTransparentGIF(w) |
| 237 | } |
| 238 | } else { |
| 239 | path, err := wavebase.ExpandHomeDir(path) |
| 240 | if err != nil { |
| 241 | http.Error(w, err.Error(), http.StatusBadRequest) |
| 242 | } |
| 243 | http.ServeFile(w, r, path) |
| 244 | } |
| 245 | } |
| 246 | |
| 247 | func handleStreamFileFromReader(w http.ResponseWriter, r *http.Request, path string, no404 bool) error { |
| 248 | startTime := time.Now() |
no test coverage detected