Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions github_webhook/webhook.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,6 +2,7 @@
import hashlib
import hmac
import logging
import json

import six
from flask import abort, request
Expand DownExpand Up@@ -58,7 +59,12 @@ def _postreceive(self):
abort(400, "Invalid signature")

event_type = _get_header("X-Github-Event")
data = request.get_json()
content_type = _get_header('content-type')

if content_type == "application/x-www-form-urlencoded":
data = json.loads(request.form.to_dict(flat=True)["payload"])
else:
data = request.get_json()

if data is None:
abort(400, "Request body must contain json")
Expand DownExpand Up@@ -121,7 +127,6 @@ def _format_event(event_type, data):
except KeyError:
return event_type


# -----------------------------------------------------------------------------
# Copyright 2015 Bloomberg Finance L.P.
#
Expand Down