rm last printf in http

This commit is contained in:
Jimmy Zelinskie 2014-07-12 01:52:27 -04:00
parent 292c15e519
commit 8ddbf32002

View file

@ -5,7 +5,6 @@
package http package http
import ( import (
"fmt"
"net/http" "net/http"
"time" "time"
@ -13,6 +12,7 @@ import (
"github.com/julienschmidt/httprouter" "github.com/julienschmidt/httprouter"
"github.com/stretchr/graceful" "github.com/stretchr/graceful"
"github.com/chihaya/bencode"
"github.com/chihaya/chihaya/config" "github.com/chihaya/chihaya/config"
"github.com/chihaya/chihaya/drivers/backend" "github.com/chihaya/chihaya/drivers/backend"
"github.com/chihaya/chihaya/drivers/tracker" "github.com/chihaya/chihaya/drivers/tracker"
@ -97,6 +97,9 @@ func Serve(cfg *config.Config) {
} }
func fail(w http.ResponseWriter, r *http.Request, err error) { func fail(w http.ResponseWriter, r *http.Request, err error) {
errmsg := err.Error() dict := bencode.NewDict()
fmt.Fprintf(w, "d14:failure reason%d:%se", len(errmsg), errmsg) dict["failure reason"] = err.Error()
bencoder := bencode.NewEncoder(w)
bencoder.Encode(dict)
} }