@@ -108,19 +108,28 @@ protected function headers() {
108108 return $ this ->headers ;
109109 }
110110
111- if ( function_exists ( 'getallheaders ' ) ) {
112-
113- $ this ->headers = getallheaders ();
114- return $ this ->headers ;
115- }
116- /**
117- * Nginx and pre 5.4 workaround.
118- * @see http://www.php.net/manual/en/function.getallheaders.php
119- */
120111 $ this ->headers = array ();
121- foreach ( $ _SERVER as $ name => $ value ) {
122- if ( 'HTTP_ ' === substr ( $ name , 0 , 5 ) ) {
123- $ this ->headers [ str_replace ( ' ' , '- ' , ucwords ( strtolower ( str_replace ( '_ ' , ' ' , substr ( $ name , 5 ) ) ) ) ) ] = $ value ;
112+ if ( function_exists ( 'getallheaders ' ) ) {
113+ $ headers = getallheaders ();
114+ // github webhook
115+ // content-type: application/json
116+ // Expect:
117+ // User-Agent: GitHub-Hookshot/7a71d82
118+ // X-GitHub-Delivery: a331b200-2537-11e8-9d7e-ce0853020b44
119+ // X-GitHub-Event: push
120+ // X-Hub-Signature: sha1=98185ffa2c4684c9a1324c57086709acca9dddc7
121+ foreach ( $ headers as $ name => $ value ) {
122+ $ this ->headers [ str_replace ( ' ' , '- ' , ucwords ( strtolower ( str_replace ( '_ ' , ' ' , $ name ) ) ) ) ] = $ value ;
123+ }
124+ } else {
125+ /**
126+ * Nginx and pre 5.4 workaround.
127+ * @see http://www.php.net/manual/en/function.getallheaders.php
128+ */
129+ foreach ( $ _SERVER as $ name => $ value ) {
130+ if ( 'HTTP_ ' === substr ( $ name , 0 , 5 ) ) {
131+ $ this ->headers [ str_replace ( ' ' , '- ' , ucwords ( strtolower ( str_replace ( '_ ' , ' ' , substr ( $ name , 5 ) ) ) ) ) ] = $ value ;
132+ }
124133 }
125134 }
126135
0 commit comments