Do not return HTTP 200 OK on exception
Closed this issue · 1 comments
rangoy commented
I've put a cache server in front of a ogcserver.
When something goes temporarily wrong in the generation of the tiles, a exception is thrown.
What is strange, and in my opinion wrong is that the server still returns HTTP 200 OK, which casues the cache server to wrongly believe that this should be cached.
I've patched my staging server with this patch:
--- a/ogcserver/wsgi.py
+++ b/ogcserver/wsgi.py
@@ -115,7 +115,7 @@ class WSGIApp:
ogcparams['HTTP_USER_AGENT'] = environ.get('HTTP_USER_AGENT', '')
response = requesthandler(ogcparams)
- except:
+ except Exception as e:
version = reqparams.get('version', None)
if not version:
version = Version()
@@ -125,7 +125,10 @@ class WSGIApp:
eh = ExceptionHandler130(self.debug,base,self.home_html)
else:
eh = ExceptionHandler111(self.debug,base,self.home_html)
- response = eh.getresponse(reqparams)
+ #response = eh.getresponse(reqparams)
+ response_headers = [('Cache-Control','Max-Age=0') ]
+ start_response('500 Internal Server Error', response_headers)
+ yield "500 Internal Server Error "
response_headers = [('Content-Type', response.content_type),('Content-Length', str(len(response.content)))]
if self.max_age:
response_headers.append(('Cache-Control', self.max_age))
manelclos commented
Hi Rangoy, thanks for the report. I was also having the same problem. Can you please check the fix works for you?