From c4168bfeb5bef26382f4f4f56807c48f0cd8240a Mon Sep 17 00:00:00 2001 From: Feike Steenbergen Date: Tue, 12 May 2015 14:56:02 +0200 Subject: [PATCH] Bugfix: Headers sent before http status for the pg_status page. --- helpers/statuspage.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/helpers/statuspage.py b/helpers/statuspage.py index cec68432..2819beeb 100644 --- a/helpers/statuspage.py +++ b/helpers/statuspage.py @@ -8,6 +8,7 @@ import json class StatusPage(BaseHTTPRequestHandler): def do_GET(self): + content_type='text/plain' if self.path == '/pg_master': if not self.pg_is_in_recovery(): response, content = 200, 'I am currently a master' @@ -20,10 +21,12 @@ class StatusPage(BaseHTTPRequestHandler): response, content = 503, 'I am not a slave' elif self.path == '/pg_status': response, content = 200, self.pg_status() + content_type = 'application/json' else: response, content = 404, 'Page not found' self.send_response(response) + self.send_header('Content-Type', content_type) self.end_headers() self.wfile.write(content) @@ -47,8 +50,6 @@ class StatusPage(BaseHTTPRequestHandler): status = {'role': ('master' if not res[0] else 'slave'), 'recovery': {'last_transaction_timestamp': res[1]}, 'server': {'hostaddr': res[3], 'port': res[4], 'start_time': res[5]}} - self.send_header('Content-Type', 'application/json') - return json.dumps(status)