title: Special character with Spring authentication
body: <p>I use the below code where I set credentials for basic http authentication to my server that uses Spring Security. 
  Unfortunately I have problem with special characters like é,ò etc... I receive on server the question mark instead of correct character
  Someone know how to resolve it? I've been finding to set encoding without success</p>
  
  <pre><code>import org.apache.http.auth.AuthScope;
  import org.apache.http.auth.UsernamePasswordCredentials;
  import org.apache.http.client.CredentialsProvider;
  import org.apache.http.client.HttpClient;
  import org.apache.http.impl.client.BasicCredentialsProvider;
  import org.apache.http.impl.client.HttpClients;
  import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
  import org.springframework.web.client.RestTemplate;
  
  public class RestClient extends RestTemplate { 
     public RestClient(String username, String password) {
           CredentialsProvider credsProvider = new BasicCredentialsProvider();
           credsProvider.setCredentials(
                   new AuthScope(null, -1),
                   new UsernamePasswordCredentials(username, password));
           HttpClient httpClient = HttpClients.custom().setDefaultCredentialsProvider(credsProvider).build();
           setRequestFactory(new HttpComponentsClientHttpRequestFactory(httpClient));
          }
      }
  </code></pre>
  
  <p>Then I call web service with spring class:</p>
  
  <pre><code>RestClient restClient = new RestClient(username, password);
  response = restClient.getForObject(addQueryParam(url, queryParams), Response.class);
  </code></pre>
  
  <p><strong><em>UPDATE:</em></strong></p>
  
  <p>Using this code I have the same error (question mark instead of special character). Some idea?</p>
  
  <pre><code>public class RestClient extends RestTemplate {
      private static RestClient instance;
  
      private RestClient(String username, String password) {
          CredentialsProvider credsProvider = new BasicCredentialsProvider();
          credsProvider.setCredentials(
                  new AuthScope(null, -1),
                  new UsernamePasswordCredentials(username, password));
          HttpClient httpClient = HttpClients.custom().setDefaultCredentialsProvider(credsProvider).build();
          setRequestFactory(new HttpComponentsClientHttpRequestFactory(httpClient));
      }
  
      public static synchronized RestClient getInstance(String username, String password){
          if (instance == null){
              instance = new RestClient(username, password);
              instance.getMessageConverters().add(0, new StringHttpMessageConverter(Charset.forName("UTF-8")));
          }
          return instance;
  
      }  
  }
  </code></pre>