List:Commits« Previous MessageNext Message »
From:Dyre Tjeldvoll Date:January 10 2013 12:19pm
Subject:bzr push into mysql-5.5-cluster-7.2 branch (Dyre.Tjeldvoll:4149 to 4150)
View as plain text  
 4150 Dyre Tjeldvoll	2013-01-10
      Better handling of 404 and 500 errors

    modified:
      storage/ndb/mcc/request_handler.py
 4149 Dyre Tjeldvoll	2013-01-07
      Add support for HEAD requests which appear to be issued by modern versions of Firefox

    modified:
      storage/ndb/mcc/request_handler.py
=== modified file 'storage/ndb/mcc/request_handler.py'
--- a/storage/ndb/mcc/request_handler.py	2013-01-07 11:53:42 +0000
+++ b/storage/ndb/mcc/request_handler.py	2013-01-10 12:18:49 +0000
@@ -401,8 +401,19 @@ class ConfiguratorHandler(BaseHTTPServer
     def _do_file_req(self, rt):
         """Handles file requests. Attempts to guess 
         the MIME type and set the Content-Type accordingly."""
-        log_thread_name()
         try:
+            log_thread_name()
+            self.server.logger.debug(rt+' fdir='+self.server.opts['fdir']+ " path="+os.path.normpath(self.path))
+            fn = os.path.join(self.server.opts['fdir'], os.path.normpath(self.path[1:]))
+            try:
+                os.stat(fn)                
+            except OSError as ose:
+                self.server.logger.exception(rt + ' '+self.path+ ' failed')
+                if ose.errno == errno.ENOENT:
+                    self.send_error(404, self.path+'=> file://'+ose.filename+' does not exist')
+                    return
+                raise
+
             self.send_response(200)
             (ct, enc) = mimetypes.guess_type(self.path)
             if (ct): 
@@ -410,24 +421,10 @@ class ConfiguratorHandler(BaseHTTPServer
             if (enc):
                 self.send_header('Content-Encoding',  enc)
             self.end_headers()
-            self.server.logger.debug(rt+' fdir='+self.server.opts['fdir']+ " path="+os.path.normpath(self.path))
-            fn = os.path.join(self.server.opts['fdir'], os.path.normpath(self.path[1:]))
-            
-            if rt == 'HEAD':
-                os.stat(fn)                
-            elif rt == 'GET':
+            if rt == 'GET':
                 with open(fn, "rb") as f:
                     self.wfile.write(f.read()+'\r\n\r\n')
-            else:
-                raise Exception('Unknown file request type: '+rt)
             
-        except OSError as ose:
-            self.server.logger.exception(rt + ' '+self.path+ ' failed')
-            if ose.errno == errno.ENOENT:
-                self.send_error(404,'File '+self.path+'('+ose.filename+') does not exist.')
-            else:
-                self.send_error(500,'Unexpected exception occured: '+rt+' '+self.path+'\n'+traceback.format_exc()) # Some other number
-
         except:
             self.server.logger.exception(rt + ' '+self.path+ ' failed')
             self.send_error(500,'Unexpected exception occured while processing: '+rt+' '+self.path+'\n'+traceback.format_exc()) # Some other number

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-5.5-cluster-7.2 branch (Dyre.Tjeldvoll:4149 to 4150) Dyre Tjeldvoll18 Feb