LCOV - code coverage report
Current view: top level - envoy/http - codes.h (source / functions) Hit Total Coverage
Test: coverage.dat Lines: 1 1 100.0 %
Date: 2024-01-05 06:35:25 Functions: 1 1 100.0 %

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include <chrono>
       4             : 
       5             : #include "envoy/stats/scope.h"
       6             : 
       7             : namespace Envoy {
       8             : namespace Http {
       9             : 
      10             : /**
      11             :  * HTTP response codes.
      12             :  * http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
      13             :  */
      14             : enum class Code : uint16_t {
      15             :   // clang-format off
      16             :   Continue                      = 100,
      17             :   SwitchingProtocols            = 101,
      18             : 
      19             :   OK                            = 200,
      20             :   Created                       = 201,
      21             :   Accepted                      = 202,
      22             :   NonAuthoritativeInformation   = 203,
      23             :   NoContent                     = 204,
      24             :   ResetContent                  = 205,
      25             :   PartialContent                = 206,
      26             :   MultiStatus                   = 207,
      27             :   AlreadyReported               = 208,
      28             :   IMUsed                        = 226,
      29             : 
      30             :   MultipleChoices               = 300,
      31             :   MovedPermanently              = 301,
      32             :   Found                         = 302,
      33             :   SeeOther                      = 303,
      34             :   NotModified                   = 304,
      35             :   UseProxy                      = 305,
      36             :   TemporaryRedirect             = 307,
      37             :   PermanentRedirect             = 308,
      38             : 
      39             :   BadRequest                    = 400,
      40             :   Unauthorized                  = 401,
      41             :   PaymentRequired               = 402,
      42             :   Forbidden                     = 403,
      43             :   NotFound                      = 404,
      44             :   MethodNotAllowed              = 405,
      45             :   NotAcceptable                 = 406,
      46             :   ProxyAuthenticationRequired   = 407,
      47             :   RequestTimeout                = 408,
      48             :   Conflict                      = 409,
      49             :   Gone                          = 410,
      50             :   LengthRequired                = 411,
      51             :   PreconditionFailed            = 412,
      52             :   PayloadTooLarge               = 413,
      53             :   URITooLong                    = 414,
      54             :   UnsupportedMediaType          = 415,
      55             :   RangeNotSatisfiable           = 416,
      56             :   ExpectationFailed             = 417,
      57             :   MisdirectedRequest            = 421,
      58             :   UnprocessableEntity           = 422,
      59             :   Locked                        = 423,
      60             :   FailedDependency              = 424,
      61             :   TooEarly                      = 425,
      62             :   UpgradeRequired               = 426,
      63             :   PreconditionRequired          = 428,
      64             :   TooManyRequests               = 429,
      65             :   RequestHeaderFieldsTooLarge   = 431,
      66             : 
      67             :   InternalServerError           = 500,
      68             :   NotImplemented                = 501,
      69             :   BadGateway                    = 502,
      70             :   ServiceUnavailable            = 503,
      71             :   GatewayTimeout                = 504,
      72             :   HTTPVersionNotSupported       = 505,
      73             :   VariantAlsoNegotiates         = 506,
      74             :   InsufficientStorage           = 507,
      75             :   LoopDetected                  = 508,
      76             :   NotExtended                   = 510,
      77             :   NetworkAuthenticationRequired = 511
      78             :   // clang-format on
      79             : };
      80             : 
      81             : /**
      82             :  * Manages updating of statistics for HTTP Status Codes. Sets up string-tokens
      83             :  * for fast combining of tokens based on scope, status-code buckets (2xx,
      84             :  * 4xx...), and exact status code.
      85             :  */
      86             : class CodeStats {
      87             : public:
      88         589 :   virtual ~CodeStats() = default;
      89             : 
      90             :   struct ResponseStatInfo;
      91             :   struct ResponseTimingInfo;
      92             : 
      93             :   /**
      94             :    * Charge a simple response stat to an upstream. exclude_http_code_stats will skip charging
      95             :    * HTTP group/individual status code stats if set to True.
      96             :    */
      97             :   virtual void chargeBasicResponseStat(Stats::Scope& scope, Stats::StatName prefix,
      98             :                                        Code response_code, bool exclude_http_code_stats) const PURE;
      99             : 
     100             :   /**
     101             :    * Charge a response stat to both agg counters (*xx) as well as code specific counters. This
     102             :    * routine also looks for the x-envoy-upstream-canary header and if it is set, also charges
     103             :    * canary stats. exclude_http_code_stats will skip charging HTTP group/individual status
     104             :    * code stats if set to True.
     105             :    */
     106             :   virtual void chargeResponseStat(const ResponseStatInfo& info,
     107             :                                   bool exclude_http_code_stats) const PURE;
     108             : 
     109             :   /**
     110             :    * Charge a response timing to the various dynamic stat postfixes.
     111             :    */
     112             :   virtual void chargeResponseTiming(const ResponseTimingInfo& info) const PURE;
     113             : };
     114             : 
     115             : } // namespace Http
     116             : } // namespace Envoy

Generated by: LCOV version 1.15