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

hazendaz / httpunit / 755

14 Feb 2026 07:14PM UTC coverage: 80.526%. Remained the same
755

push

github

hazendaz
[ci] Fix badge

3213 of 4105 branches covered (78.27%)

Branch coverage included in aggregate %.

8245 of 10124 relevant lines covered (81.44%)

0.81 hits per line

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

93.94
/src/main/java/com/meterware/httpunit/cookies/CookieProperties.java
1
/*
2
 * SPDX-License-Identifier: MIT
3
 * See LICENSE file for details.
4
 *
5
 * Copyright 2000-2026 Russell Gold
6
 * Copyright 2021-2000 hazendaz
7
 */
8
package com.meterware.httpunit.cookies;
9

10
import java.util.ArrayList;
11
import java.util.Iterator;
12
import java.util.List;
13

14
/**
15
 * Controls behavior for cookies.
16
 */
17
public class CookieProperties {
×
18

19
    /** If true, domain matching follows the spec. If false, permits any domain which is a prefix of the host. **/
20
    private static boolean _domainMatchingStrict = true;
1✔
21

22
    /** If true, path matching follows the spec. If false, permits any path. **/
23
    private static boolean _pathMatchingStrict = true;
1✔
24

25
    /** A collection of listeners for cookie events. **/
26
    private static ArrayList<CookieListener> _listeners;
27

28
    /**
29
     * Reset.
30
     */
31
    public static void reset() {
32
        _domainMatchingStrict = true;
1✔
33
        _pathMatchingStrict = true;
1✔
34
        _listeners = null;
1✔
35
    }
1✔
36

37
    /**
38
     * Returns true (the default) if cookies should be rejected if they specify a domain which is not a suffix of the
39
     * host domain or does not contain all of the dots in that host domain name (see
40
     * <a href="http://www.faqs.org/rfcs/rfc2965.html">RFC2965</a>).
41
     *
42
     * @return true, if is domain matching strict
43
     */
44
    public static boolean isDomainMatchingStrict() {
45
        return _domainMatchingStrict;
1✔
46
    }
47

48
    /**
49
     * Specifies whether strict domain name matching must be followed.
50
     *
51
     * @param domainMatchingStrict
52
     *            the new domain matching strict
53
     */
54
    public static void setDomainMatchingStrict(boolean domainMatchingStrict) {
55
        _domainMatchingStrict = domainMatchingStrict;
1✔
56
    }
1✔
57

58
    /**
59
     * Returns true (the default) if cookies should be rejected if they specify a path which is not a prefix of the
60
     * request path (see <a href="http://www.faqs.org/rfcs/rfc2965.html">RFC2965</a>).
61
     *
62
     * @return true, if is path matching strict
63
     */
64
    public static boolean isPathMatchingStrict() {
65
        return _pathMatchingStrict;
1✔
66
    }
67

68
    /**
69
     * Specifies whether strict path name matching must be followed.
70
     *
71
     * @param pathMatchingStrict
72
     *            the new path matching strict
73
     */
74
    public static void setPathMatchingStrict(boolean pathMatchingStrict) {
75
        _pathMatchingStrict = pathMatchingStrict;
1✔
76
    }
1✔
77

78
    /**
79
     * Adds a listener for cookie events.
80
     *
81
     * @param listener
82
     *            the listener
83
     */
84
    public static void addCookieListener(CookieListener listener) {
85
        if (_listeners == null) {
1!
86
            _listeners = new ArrayList<>();
1✔
87
        }
88
        synchronized (_listeners) {
1✔
89
            _listeners.add(listener);
1✔
90
        }
1✔
91
    }
1✔
92

93
    /**
94
     * Report cookie rejected.
95
     *
96
     * @param reason
97
     *            the reason
98
     * @param attribute
99
     *            the attribute
100
     * @param source
101
     *            the source
102
     */
103
    public static void reportCookieRejected(int reason, String attribute, String source) {
104
        if (_listeners == null) {
1✔
105
            return;
1✔
106
        }
107

108
        List<CookieListener> listeners;
109
        synchronized (_listeners) {
1✔
110
            listeners = (List<CookieListener>) _listeners.clone();
1✔
111
        }
1✔
112

113
        for (Iterator<CookieListener> i = listeners.iterator(); i.hasNext();) {
1✔
114
            (i.next()).cookieRejected(source, reason, attribute);
1✔
115
        }
116
    }
1✔
117
}
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