Changeset 1087

Show
Ignore:
Timestamp:
06/11/08 17:43:45 (3 months ago)
Author:
kris
Message:

exposed the response-code from IServletResponse, and added better failure handling in Servlet

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/mango/net/servlet/Servlet.d

    r1086 r1087  
    9898        { 
    9999                char[]  name; 
     100 
     101                ulong   ok = 0, 
     102                        bad = 0, 
     103                        fail = 0; 
     104 
    100105                double  time = 0, 
    101106                        average = 0, 
     
    103108                        average4 = 0, 
    104109                        average8 = 0; 
    105                 ulong   failures = 0, 
    106                         responses = 0; 
    107                           
    108  
    109                 void update (double time) 
     110 
     111                         
     112 
     113                void update (HttpStatus status, double time) 
    110114                { 
    111                         ++responses; 
     115                        if (status.code < HttpResponseCode.BadRequest) 
     116                            ++ok; 
     117                        else 
     118                           ++bad; 
     119 
    112120                        this.time = time; 
    113121                        average2 = (average2 + time) / 2.0; 
     
    366374                     
    367375                    // update metrics 
    368                     metric.update (timer.stop); 
     376                    metric.update (response.getStatus, timer.stop); 
    369377 
    370378                    if (log) 
    371379                       { 
    372380                       char[1024] buf = void; 
    373                        log.info (log.format(buf, "{} [{.512}] - {} responses, {} failures, {}us [{}]",  
    374                                  method, request.path, metric.responses, metric.failures
     381                       log.info (log.format(buf, "{} [{.512}] - {} good, {} bad, {} fail, {}us [{}]",  
     382                                 method, request.path, metric.ok, metric.bad, metric.fail
    375383                                 cast(int)(metric.time    * 1_000_000), 
    376384                                 cast(int)(metric.average * 1_000_000) 
     
    379387                    } catch (Exception e) 
    380388                            { 
    381                             ++metric.failures
     389                            ++metric.fail
    382390                            if (log) 
    383391                               { 
    384392                               char[1024] buf = void; 
    385                                log.error (log.format(buf, "{} [{.512}] - {} responses, {} failures: {.256}",  
    386                                           method, request.path, metric.responses, metric.failures, e)); 
     393                               log.error (log.format(buf, "{} [{.512}] - {} good, {} bad, {} fail: {.256}",  
     394                                          method, request.path, metric.ok, metric.bad, metric.fail, e)); 
    387395                               } 
    388396                            throw exception; 
  • trunk/mango/net/servlet/ServletResponse.d

    r1039 r1087  
    5656                // reset HttpRequest 
    5757                super.reset(); 
     58        } 
     59 
     60        /********************************************************************** 
     61 
     62                Return the current response status 
     63 
     64        **********************************************************************/ 
     65 
     66        HttpStatus getStatus () 
     67        { 
     68                return super.getStatus; 
    5869        } 
    5970 
  • trunk/mango/net/servlet/model/IServletResponse.d

    r957 r1087  
    2828interface IServletResponse 
    2929{ 
     30        /********************************************************************** 
     31 
     32                Return the current response status 
     33 
     34        **********************************************************************/ 
     35 
     36        HttpStatus getStatus (); 
     37 
    3038        /********************************************************************** 
    3139