• 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

94.12
/src/main/java/com/meterware/httpunit/protocol/URLEncodedString.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.protocol;
9

10
import java.net.URLEncoder;
11
import java.nio.charset.Charset;
12

13
/**
14
 * The Class URLEncodedString.
15
 */
16
public class URLEncodedString implements ParameterProcessor {
1✔
17

18
    /** The Constant DEFAULT_BUFFER_SIZE. */
19
    public static final int DEFAULT_BUFFER_SIZE = 128;
20

21
    /** The buffer. */
22
    private StringBuilder _buffer = new StringBuilder(DEFAULT_BUFFER_SIZE);
1✔
23

24
    /** The have parameters. */
25
    private boolean _haveParameters = false;
1✔
26

27
    /**
28
     * Gets the string.
29
     *
30
     * @return the string
31
     */
32
    public String getString() {
33
        return _buffer.toString();
1✔
34
    }
35

36
    @Override
37
    public void addParameter(String name, String value, String characterSet) {
38
        if (_haveParameters) {
1✔
39
            _buffer.append('&');
1✔
40
        }
41
        _buffer.append(encode(name, characterSet));
1✔
42
        if (value != null) {
1✔
43
            _buffer.append('=').append(encode(value, characterSet));
1✔
44
        }
45
        _haveParameters = true;
1✔
46
    }
1✔
47

48
    @Override
49
    public void addFile(String parameterName, UploadFileSpec fileSpec) {
50
        throw new RuntimeException("May not URL-encode a file upload request");
×
51
    }
52

53
    /**
54
     * Returns a URL-encoded version of the string.
55
     *
56
     * @param source
57
     *            the source
58
     * @param characterSet
59
     *            the character set
60
     *
61
     * @return the string
62
     */
63
    private String encode(String source, String characterSet) {
64
        return URLEncoder.encode(source, Charset.forName(characterSet));
1✔
65
    }
66

67
}
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