Accept application/json in GitHub change hook and accept pings

This fixes the GitHub change hook to work better, by accepting ping requests (otherwise, GitHub will report that the change hook is broken) and also by supporting the alternate content option, application/json.

I pulled the relevant code from contrib/github_buildbot.py, this code is now more-or-less in line with that code.

I updated the unit tests to include the necessary HTTP headers, Content-Type and X-GitHub-Event.