• 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

76.92
/src/main/java/com/meterware/httpunit/protocol/URLEncodedMessageBody.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 com.meterware.httpunit.HttpUnitOptions;
11

12
import java.io.IOException;
13
import java.io.OutputStream;
14
import java.nio.charset.StandardCharsets;
15

16
/**
17
 * A POST method request message body which uses the default URL encoding.
18
 **/
19
class URLEncodedMessageBody extends MessageBody {
20

21
    /**
22
     * Instantiates a new URL encoded message body.
23
     *
24
     * @param characterSet
25
     *            the character set
26
     */
27
    URLEncodedMessageBody(String characterSet) {
28
        super(characterSet);
1✔
29
    }
1✔
30

31
    /**
32
     * Returns the content type of this message body.
33
     **/
34
    @Override
35
    public String getContentType() {
36
        return "application/x-www-form-urlencoded"
1✔
37
                + (!HttpUnitOptions.isPostIncludesCharset() ? "" : "; charset=" + getCharacterSet());
1!
38
    }
39

40
    /**
41
     * Transmits the body of this request as a sequence of bytes.
42
     **/
43
    @Override
44
    public void writeTo(OutputStream outputStream, ParameterCollection parameters) throws IOException {
45
        outputStream.write(getParameterString(parameters).getBytes(StandardCharsets.UTF_8));
1✔
46
    }
1✔
47

48
    /**
49
     * Gets the parameter string.
50
     *
51
     * @param parameters
52
     *            the parameters
53
     *
54
     * @return the parameter string
55
     */
56
    private String getParameterString(ParameterCollection parameters) {
57
        try {
58
            URLEncodedString encoder = new URLEncodedString();
1✔
59
            parameters.recordParameters(encoder);
1✔
60
            return encoder.getString();
1✔
61
        } catch (IOException e) {
×
62
            throw new RuntimeException("Programming error: " + e); // should never happen
×
63
        }
64
    }
65
}
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