Proper caching
This commit is contained in:
@@ -26,7 +26,7 @@ func HandlePropfindRequest(w http.ResponseWriter, r *http.Request, t *torrent.To
|
||||
}
|
||||
if err != nil {
|
||||
log.Printf("Cannot marshal xml: %v\n", err.Error())
|
||||
http.Error(w, fmt.Sprintf("Cannot marshal xml: %v", err.Error()), http.StatusInternalServerError)
|
||||
http.Error(w, "Cannot read directory", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
if output != nil {
|
||||
@@ -54,8 +54,8 @@ func handleListOfTorrents(w http.ResponseWriter, r *http.Request, t *torrent.Tor
|
||||
allTorrents := t.GetAll()
|
||||
allTorrentsResponse, err := createMultiTorrentResponse(allTorrents)
|
||||
if err != nil {
|
||||
log.Printf("Cannot read directory: %v\n", err.Error())
|
||||
http.Error(w, fmt.Sprintf("Cannot read directory: %v", err.Error()), http.StatusInternalServerError)
|
||||
log.Printf("Cannot read directory (/torrents): %v\n", err.Error())
|
||||
http.Error(w, "Cannot read directory", http.StatusInternalServerError)
|
||||
return nil, nil
|
||||
}
|
||||
return xml.MarshalIndent(allTorrentsResponse, "", " ")
|
||||
@@ -67,15 +67,15 @@ func handleSingleTorrent(w http.ResponseWriter, r *http.Request, t *torrent.Torr
|
||||
torrentName := path.Base(requestPath)
|
||||
foundTorrents := findAllTorrentsWithName(t, torrentName)
|
||||
if len(foundTorrents) == 0 {
|
||||
log.Println("Cannot find directory")
|
||||
log.Println("Cannot find directory", requestPath)
|
||||
http.Error(w, "Cannot find directory", http.StatusNotFound)
|
||||
return nil, nil
|
||||
}
|
||||
var torrentResponse *dav.MultiStatus
|
||||
torrentResponse, err := createCombinedTorrentResponse(foundTorrents, t)
|
||||
if err != nil {
|
||||
log.Printf("Cannot read directory: %v\n", err.Error())
|
||||
http.Error(w, fmt.Sprintf("Cannot read directory: %v", err.Error()), http.StatusInternalServerError)
|
||||
log.Printf("Cannot read directory (%s): %v\n", requestPath, err.Error())
|
||||
http.Error(w, "Cannot read directory", http.StatusInternalServerError)
|
||||
return nil, nil
|
||||
}
|
||||
return xml.MarshalIndent(torrentResponse, "", " ")
|
||||
|
||||
Reference in New Issue
Block a user