unescape infohash in API
This commit is contained in:
parent
23edba6dc6
commit
c762946ed7
1 changed files with 13 additions and 2 deletions
15
http/api.go
15
http/api.go
|
@ -8,6 +8,7 @@ import (
|
|||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"github.com/julienschmidt/httprouter"
|
||||
|
||||
|
@ -30,7 +31,12 @@ func (t *Tracker) getTorrent(w http.ResponseWriter, r *http.Request, p httproute
|
|||
return http.StatusInternalServerError, err
|
||||
}
|
||||
|
||||
torrent, err := conn.FindTorrent(p.ByName("infohash"))
|
||||
infohash, err := url.QueryUnescape(p.ByName("infohash"))
|
||||
if err != nil {
|
||||
return http.StatusNotFound, err
|
||||
}
|
||||
|
||||
torrent, err := conn.FindTorrent(infohash)
|
||||
if err == tracker.ErrTorrentDNE {
|
||||
return http.StatusNotFound, err
|
||||
} else if err != nil {
|
||||
|
@ -77,7 +83,12 @@ func (t *Tracker) delTorrent(w http.ResponseWriter, r *http.Request, p httproute
|
|||
return http.StatusInternalServerError, err
|
||||
}
|
||||
|
||||
err = conn.DeleteTorrent(p.ByName("infohash"))
|
||||
infohash, err := url.QueryUnescape(p.ByName("infohash"))
|
||||
if err != nil {
|
||||
return http.StatusNotFound, err
|
||||
}
|
||||
|
||||
err = conn.DeleteTorrent(infohash)
|
||||
if err == tracker.ErrTorrentDNE {
|
||||
return http.StatusNotFound, err
|
||||
} else if err != nil {
|
||||
|
|
Loading…
Add table
Reference in a new issue