aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkongr45gpen <electrovesta@gmail.com>2016-09-16 14:14:14 +0300
committerkongr45gpen <electrovesta@gmail.com>2016-09-16 14:29:53 +0300
commit3902f3b980c0e2a885b965b4f2503244c3e68782 (patch)
tree11c8fc4d8e2272ae2a4323f9cf12711f5e35a79c
parent8a37f308903f3927b7442a38695ee0a99982a53c (diff)
downloadsupybot_github-3902f3b980c0e2a885b965b4f2503244c3e68782.tar.gz
supybot_github-3902f3b980c0e2a885b965b4f2503244c3e68782.tar.bz2
supybot_github-3902f3b980c0e2a885b965b4f2503244c3e68782.zip
Improve HTTP response
-rw-r--r--__init__.py8
-rw-r--r--local/handler/GithubHandler.py12
2 files changed, 11 insertions, 9 deletions
diff --git a/__init__.py b/__init__.py
index 52060c2..953dd50 100644
--- a/__init__.py
+++ b/__init__.py
@@ -28,6 +28,8 @@ import plugin
reload(plugin) # In case we're being reloaded.
# Add more reloads here if you add third-party modules and want them to be
# reloaded when this plugin is reloaded. Don't forget to import them as well!
+import local.globals
+import local.utility
import local.handler.GithubHandler as RequestHandler
import local.handler.PingHandler
import local.handler.PushHandler
@@ -42,8 +44,8 @@ import local.handler.IssueCommentHandler
import local.theme.Theme
import local.theme.DefaultTheme
import local.theme.CompactTheme
-import local.utility
-import local.globals
+reload(local.globals)
+reload(local.utility)
reload(RequestHandler)
reload(local.handler.PingHandler)
reload(local.handler.PushHandler)
@@ -58,8 +60,6 @@ reload(local.handler.IssueCommentHandler)
reload(local.theme.Theme)
reload(local.theme.DefaultTheme)
reload(local.theme.CompactTheme)
-reload(local.utility)
-reload(local.globals)
local.globals.init()
diff --git a/local/handler/GithubHandler.py b/local/handler/GithubHandler.py
index 909484e..b791298 100644
--- a/local/handler/GithubHandler.py
+++ b/local/handler/GithubHandler.py
@@ -95,22 +95,24 @@ class GithubHandler(BaseHTTPServer.BaseHTTPRequestHandler):
try:
s.send_response(200)
- s.send_header('Content-type', 'text/html')
+ s.send_header('Content-type', 'text/plain')
s.end_headers()
- s.wfile.write("Thanks, you're awesome.\n")
+ s.wfile.write("Thanks!\n")
s.wfile.write(s.path.split('/'))
+ s.wfile.write("\n")
except socket.error:
pass
if requireCode and receivedcode != configValue('passcode'):
# The password is wrong
- s.wfile.write("The password is wrong")
+ s.wfile.write("The password is wrong\n")
return
+ # Handle Github secrets
secret = getChannelSecret(channel)
if secret is not None:
if not 'X-Hub-Signature' in s.headers:
- s.wfile.write("This channel requires a secret")
+ s.wfile.write("This channel requires a secret\n")
return
digest = "sha1=%s" % (hmac.new(secret, payload, hashlib.sha1).hexdigest(),)
@@ -120,7 +122,7 @@ class GithubHandler(BaseHTTPServer.BaseHTTPRequestHandler):
log.debug("provided digest: %s", provided)
if not secureCompare(digest, provided):
- s.wfile.write("Invalid secret key")
+ s.wfile.write("Invalid secret key\n")
return
brackets = parseBrackets(configValue('brackets'))

© 2014-2024 Faster IT GmbH | imprint | privacy policy