• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ThreeMammals / Ocelot / 36707038946

30 Sep 2026 11:11AM UTC coverage: 97.127% (-0.5%) from 97.638%
36707038946

push

github

web-flow
#2352 Stop building upstream header templates from request headers in dynamic routing (#2427)

* #2352 Add tests reproducing RegexParseException for browser headers in dynamic routing
* #2352 Stop building upstream header templates from request headers in dynamic routing
* Update scripting in workflows related to code coverage copying the version from develop
* Code review by @raman-m
* Enable builds for release/25.0 branch
---------
Co-authored-by: Raman Maksimchuk <dotnet044@gmail.com>

6728 of 6927 relevant lines covered (97.13%)

3289.59 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.0
src/Responder/ErrorsToHttpStatusCodeMapper.cs
1
using Microsoft.AspNetCore.Http;
2
using Ocelot.Errors;
3

4
namespace Ocelot.Responder;
5

6
public class ErrorsToHttpStatusCodeMapper : IErrorsToHttpStatusCodeMapper
7
{
8
    public int Map(List<Error> errors)
9
    {
39 ✔
10
        if (errors.Any(e => e.Code == OcelotErrorCode.UnauthenticatedError))
39 ✔
11
        {
2 ✔
12
            return StatusCodes.Status401Unauthorized;
2 ✔
13
        }
14

15
        if (errors.Any(e => e.Code == OcelotErrorCode.UnauthorizedError
37 ✔
16
            || e.Code == OcelotErrorCode.ClaimValueNotAuthorizedError
37 ✔
17
            || e.Code == OcelotErrorCode.ScopeNotAuthorizedError
37 ✔
18
            || e.Code == OcelotErrorCode.UserDoesNotHaveClaimError
37 ✔
19
            || e.Code == OcelotErrorCode.CannotFindClaimError
37 ✔
20
            || e.Code == OcelotErrorCode.SecurityError))
37 ✔
21
        {
7 ✔
22
            return StatusCodes.Status403Forbidden;
7 ✔
23
        }
24

25
        if (errors.Any(e => e.Code == OcelotErrorCode.QuotaExceededError))
30 ✔
26
        {
×
27
            return errors.Single(e => e.Code == OcelotErrorCode.QuotaExceededError).HttpStatusCode;
×
28
        }
29

30
        if (errors.Any(e => e.Code == OcelotErrorCode.RequestTimedOutError))
30 ✔
31
        {
2 ✔
32
            return StatusCodes.Status503ServiceUnavailable;
2 ✔
33
        }
34

35
        if (errors.Any(e => e.Code == OcelotErrorCode.RequestCanceled))
28 ✔
36
        {
×
37
            // status code refer to
38
            // https://stackoverflow.com/questions/46234679/what-is-the-correct-http-status-code-for-a-cancelled-request?answertab=votes#tab-top
39
            // https://httpstatuses.com/499
40
            return StatusCodes.Status499ClientClosedRequest;
×
41
        }
42

43
        if (errors.Any(e => e.Code == OcelotErrorCode.UnableToFindDownstreamRouteError))
28 ✔
44
        {
1 ✔
45
            return StatusCodes.Status404NotFound;
1 ✔
46
        }
47

48
        if (errors.Any(e => e.Code == OcelotErrorCode.ConnectionToDownstreamServiceError))
27 ✔
49
        {
1 ✔
50
            return StatusCodes.Status502BadGateway;
1 ✔
51
        }
52

53
        if (errors.Any(e => e.Code == OcelotErrorCode.UnableToCompleteRequestError
26 ✔
54
            || e.Code == OcelotErrorCode.CouldNotFindLoadBalancerCreator
26 ✔
55
            || e.Code == OcelotErrorCode.ErrorInvokingLoadBalancerCreator))
26 ✔
56
        {
3 ✔
57
            return StatusCodes.Status500InternalServerError;
3 ✔
58
        }
59

60
        if (errors.Any(e => e.Code == OcelotErrorCode.PayloadTooLargeError))
23 ✔
61
        {
1 ✔
62
            return StatusCodes.Status413PayloadTooLarge;
1 ✔
63
        }
64

65
        if (errors.Any(e => e.Code == OcelotErrorCode.BadRequestError))
22 ✔
66
        {
1 ✔
67
            return StatusCodes.Status400BadRequest;
1 ✔
68
        }
69

70
        return StatusCodes.Status404NotFound;
21 ✔
71
    }
39 ✔
72
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc