diff options
author | kongr45gpen <electrovesta@gmail.com> | 2016-01-21 17:34:17 +0200 |
---|---|---|
committer | kongr45gpen <electrovesta@gmail.com> | 2016-01-21 17:34:17 +0200 |
commit | 230da7e0db5a31a543bbaa24a63478f5111ceba8 (patch) | |
tree | d22eb2c050bb6d65c67ea96a33b750357f24ba22 | |
parent | 042bf88ca06f04d78bd6c7506b349934df291d31 (diff) | |
download | supybot_github-230da7e0db5a31a543bbaa24a63478f5111ceba8.tar.gz supybot_github-230da7e0db5a31a543bbaa24a63478f5111ceba8.tar.bz2 supybot_github-230da7e0db5a31a543bbaa24a63478f5111ceba8.zip |
Add support for application/json
Closes #6
-rw-r--r-- | local/handler/GithubHandler.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/local/handler/GithubHandler.py b/local/handler/GithubHandler.py index b739769..1c54ce8 100644 --- a/local/handler/GithubHandler.py +++ b/local/handler/GithubHandler.py @@ -37,15 +37,16 @@ class GithubHandler(BaseHTTPServer.BaseHTTPRequestHandler): def do_POST(s): """Respond to a POST request.""" length = int(s.headers['Content-Length']) - post_data = urlparse.parse_qs(s.rfile.read(length).decode('utf-8')) - data = json.loads(post_data['payload'][0]) + if 'content-type' not in s.headers or s.headers['content-type'] == 'application/x-www-form-urlencoded': + post_data = urlparse.parse_qs(s.rfile.read(length).decode('utf-8')) + data = json.loads(post_data['payload'][0]) + else: + data = json.loads(s.rfile.read(length).decode('utf-8')) s.send_response(200) s.send_header('Content-type', 'text/html') s.end_headers() - s.wfile.write('<!DOCTYPE html><html><head><title>Hello</title></head>') - s.wfile.write("<body><p>Thanks, you're awesome.</p>") - s.wfile.write('</body></html>\n') + s.wfile.write("Thanks, you're awesome.\n") s.wfile.write(s.path.split('/')) if 'X-GitHub-Event' in s.headers: |