[enh] display response errors to users ++ code formatting

git-svn-id: file:///srv/svn/repo/yukari/trunk@37 f3bd38d9-da89-464d-a02a-eb04e43141b5
This commit is contained in:
asciimoo 2016-11-24 21:35:37 +00:00
parent 348a8346f4
commit 7cd3fb67cd

View File

@ -213,7 +213,8 @@ func (p *Proxy) RequestHandler(ctx *fasthttp.RequestCtx) {
} }
} }
} }
log.Println("invalid request:", resp.StatusCode()) error_message := fmt.Sprintf("invalid response: %d", resp.StatusCode())
p.serveMainPage(ctx, resp.StatusCode(), errors.New(error_message))
return return
} }
@ -504,9 +505,9 @@ func sanitizeMetaAttrs(rc *RequestConfig, out io.Writer, attrs [][][]byte) {
if bytes.Equal(http_equiv, []byte("refresh")) && urlIndex != -1 { if bytes.Equal(http_equiv, []byte("refresh")) && urlIndex != -1 {
contentUrl := content[urlIndex+4:] contentUrl := content[urlIndex+4:]
// special case of <meta http-equiv="refresh" content="0; url='example.com/url.with.quote.outside'"> // special case of <meta http-equiv="refresh" content="0; url='example.com/url.with.quote.outside'">
if len(contentUrl)>=2 && (contentUrl[0] == byte('\'') || contentUrl[0] == byte('"')) { if len(contentUrl) >= 2 && (contentUrl[0] == byte('\'') || contentUrl[0] == byte('"')) {
if contentUrl[0] == contentUrl[len(contentUrl)-1] { if contentUrl[0] == contentUrl[len(contentUrl)-1] {
contentUrl=contentUrl[1:len(contentUrl)-1] contentUrl = contentUrl[1 : len(contentUrl)-1]
} }
} }
// output proxify result // output proxify result