From 00bd22404124bd9fca88ff099c41b3bddd95a8bd Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 22 Nov 2016 13:50:27 +0000 Subject: [PATCH] [mod] different HTTP status codes according to the errors : * 200 - no URL * 403 - invalid mortyhash, or javascript content * 500 - error parsing URI or getting the webpage * 501 - .onion domain * 503 - no Content-Type header in the response, or error decoding content * 504 - timeout git-svn-id: file:///srv/svn/repo/yukari/trunk@35 f3bd38d9-da89-464d-a02a-eb04e43141b5 --- morty.go | 89 +++++++++++++++++++++++++++----------------------------- 1 file changed, 43 insertions(+), 46 deletions(-) diff --git a/morty.go b/morty.go index 1acabc4..9012cc9 100644 --- a/morty.go +++ b/morty.go @@ -109,13 +109,13 @@ var HTML_FORM_EXTENSION string = ` -

This is a proxified and sanitized view of the page,
visit original site.

+

This is a proxified and sanitized view of the page,
visit original site.

-
-

MortyProxy

-`)) +

MortyProxy

`)) if err != nil { - ctx.SetStatusCode(404) log.Println("error:", err) ctx.Write([]byte("

Error: ")) ctx.Write([]byte(html.EscapeString(err.Error()))) ctx.Write([]byte("

")) - } else { - ctx.SetStatusCode(200) } if p.Key == nil { ctx.Write([]byte(` -
- Visit url: - -
`)) +
+ Visit url: + +
`)) } else { ctx.Write([]byte(`

Warning! This instance does not support direct URL opening.

`)) } ctx.Write([]byte(` -
- + `)) }