1

I am looking at the Content Encoding field in the HTTP Request sampler. Don't confuse this with the HTTP Content-Type header.

By default the value in the Content Encoding field is empty. What does empty mean? What is the default content encoding for jmeter HTTPRequest? Is it ASCII or ANSI or UTF-8?

This guide only mentions that it is not a required field.

enter image description here

variable
  • 8,262
  • 9
  • 95
  • 215

3 Answers3

2

Dmitri's answer points to code related to encoding of query strings, but this led me to looking at the code of PostWriter class which creates the actual body of the request - and if sampler does not provide a content encoding - ISO-8859-1 is used for encoding of the body:

public static final String ENCODING = StandardCharsets.ISO_8859_1.name();

...

String contentEncoding = sampler.getContentEncoding();
if(contentEncoding == null || contentEncoding.length() == 0) {
    contentEncoding = ENCODING;
}
Tomasz Poradowski
  • 1,251
  • 11
  • 12
0

To point out why I downvoted the reply above (Dmitri T's answer):

enter image description here

I had issues with spanish accents and characters, and I spent hours trying to figure it out, assuming the above answers: that leaving it blank is equivalent to UTF-8. After specifically setting it to UTF-8, no more spanish characters issues.

SO, DO NOT LEAVE BLANK IF YOU NEED UTF-8.

Bogdan U
  • 153
  • 2
  • 14
-1

As per JMeter 5.2

  1. Looking into HTTPSamplerBase.java:1136

    // Check if the sampler has a specified content encoding
    if (JOrphanUtils.isBlank(lContentEncoding)) {
        // We use the encoding which should be used according to the HTTP spec, which is UTF-8
        lContentEncoding = EncoderCache.URL_ARGUMENT_ENCODING;
    }
    
  2. Looking into EncoderCache:31

    /** The encoding which should be usd for URLs, according to HTTP specification */
    public static final String URL_ARGUMENT_ENCODING = StandardCharsets.UTF_8.name();
    

So leaving the field blank is equal to setting it to UTF-8

Dmitri T
  • 159,985
  • 5
  • 83
  • 133
  • 1
    I don't think this is right. While trying to POST a JSON to an API, I can see that if I leave the content encoding field blank, then the request fails. But if I set it to UTF-8, then it works. – variable Feb 12 '20 at 04:28