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

Waffle / waffle / 6364

01 Feb 2026 02:07AM UTC coverage: 46.217%. Remained the same
6364

push

github

web-flow
Merge pull request #3206 from Waffle/renovate/checkstyle.version

Update dependency com.puppycrawl.tools:checkstyle to v13.1.0

276 of 734 branches covered (37.6%)

Branch coverage included in aggregate %.

1019 of 2068 relevant lines covered (49.27%)

1.0 hits per line

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

85.29
/Source/JNA/waffle-jna/src/main/java/waffle/util/CorsPreFlightCheck.java
1
/*
2
 * SPDX-License-Identifier: MIT
3
 * See LICENSE file for details.
4
 *
5
 * Copyright 2010-2026 The Waffle Project Contributors: https://github.com/Waffle/waffle/graphs/contributors
6
 */
7
package waffle.util;
8

9
import java.util.ArrayList;
10
import java.util.Arrays;
11
import java.util.List;
12

13
import javax.servlet.http.HttpServletRequest;
14

15
import org.slf4j.Logger;
16
import org.slf4j.LoggerFactory;
17

18
/**
19
 * The Class CorsPrefFlightCheck.
20
 */
21
public final class CorsPreFlightCheck {
22

23
    /** The logger. */
24
    private static final Logger LOGGER = LoggerFactory.getLogger(CorsPreFlightCheck.class);
2✔
25

26
    /** The Constant preflightAttributeValue. */
27
    private static final String PRE_FLIGHT_ATTRIBUTE_VALUE = "PRE_FLIGHT";
28

29
    /** The Constant CORS_PRE_FLIGHT_HEADERS. */
30
    private static final List<String> CORS_PRE_FLIGHT_HEADERS = new ArrayList<>(
2✔
31
            Arrays.asList("Access-Control-Request-Method", "Access-Control-Request-Headers", "Origin"));
2✔
32

33
    /**
34
     * Prevent Instantiation.
35
     */
36
    private CorsPreFlightCheck() {
37
        // Do Nothing
38
    }
39

40
    /**
41
     * Checks if is preflight.
42
     *
43
     * @param request
44
     *            the request
45
     *
46
     * @return true, if is preflight
47
     */
48
    public static boolean isPreflight(final HttpServletRequest request) {
49

50
        final String corsRequestType = (String) request.getAttribute("cors.request.type");
2✔
51

52
        CorsPreFlightCheck.LOGGER
2✔
53
                .debug("[waffle.util.CorsPreflightCheck] Request is CORS preflight; continue filter chain");
2✔
54

55
        // Method MUST be an OPTIONS Method to be a preflight Request
56
        final String method = request.getMethod();
2✔
57
        if (method == null || !method.equalsIgnoreCase("OPTIONS")) {
2✔
58
            return false;
2✔
59
        }
60

61
        CorsPreFlightCheck.LOGGER.debug("[waffle.util.CorsPreflightCheck] check for PRE_FLIGHT Attribute");
2✔
62

63
        /*
64
         * Support Apache CorsFilter which would already add the Attribute cors.request.type with a value "PRE_FLIGHT"
65
         */
66
        if (corsRequestType != null
2!
67
                && corsRequestType.equalsIgnoreCase(CorsPreFlightCheck.PRE_FLIGHT_ATTRIBUTE_VALUE)) {
×
68
            return true;
×
69
        } else {
70
            /*
71
             * it is OPTIONS and it is not an CorsFilter PRE_FLIGHT request make sure that the request contains all of
72
             * the CORS preflight Headers
73
             */
74
            CorsPreFlightCheck.LOGGER.debug("[waffle.util.CorsPreflightCheck] check headers");
2✔
75

76
            for (final String header : CorsPreFlightCheck.CORS_PRE_FLIGHT_HEADERS) {
2✔
77
                final String headerValue = request.getHeader(header);
2✔
78
                CorsPreFlightCheck.LOGGER.debug("[waffle.util.CorsPreflightCheck] {}", header);
2✔
79

80
                if (headerValue == null) {
2✔
81
                    /* one of the CORS pre-flight headers is missing */
82
                    return false;
2✔
83
                }
84
            }
2✔
85
            CorsPreFlightCheck.LOGGER.debug("[waffle.util.CorsPreflightCheck] is preflight");
2✔
86

87
            return true;
2✔
88
        }
89
    }
90
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc