Fix HTTP handling of git-pull-hook
authorJan Dittberner <jandd@cacert.org>
Sat, 14 Apr 2018 18:25:14 +0000 (20:25 +0200)
committerJan Dittberner <jandd@cacert.org>
Sat, 14 Apr 2018 18:25:14 +0000 (20:25 +0200)
sitemodules/profiles/files/puppet_server/git-pull-hook

index d8761f5..78f75c3 100755 (executable)
@@ -57,7 +57,7 @@ class GitHookRequestHandler(BaseHTTPRequestHandler):
                            GIT_DIRECTORY, e)
         self.send_response(HTTPStatus.OK)
         self.send_header('Content-Type', 'text/plain; charset=utf8')
-        self.flush_headers()
+        self.end_headers()
         self.wfile.write(("updated %s" % GIT_DIRECTORY).encode('UTF-8'))
 
     # noinspection PyPep8Naming
@@ -72,14 +72,15 @@ class GitHookRequestHandler(BaseHTTPRequestHandler):
                 self._handle_pull()
             else:
                 self.send_response(HTTPStatus.UNAUTHORIZED)
-                self.flush_headers()
+                self.end_headers()
         elif self.path == '/health':
             self.send_response(HTTPStatus.OK)
-            self.flush_headers()
+            self.send_header('Content-Type', 'text/plain; charset=utf8')
+            self.end_headers()
             self.wfile.write(b"I'm healthy!")
         else:
             self.send_error(HTTPStatus.BAD_REQUEST)
-            self.flush_headers()
+            self.end_headers()
             self.wfile.write(b"You requested something I do not understand")