title: Passing basic auth credentials with every request with HtmlUnit WebClient
body: <p>I'm trying to write a simple smoke test for a web application.</p>
  
  <p>The application normally uses form based authentication, but accepts basic auth as well, but since the default is form based authentication, it never sends an authentication required, but instead just sends the login form.</p>
  
  <p>In the test I try to send the basic auth header using</p>
  
  <pre><code>WebClient webClient = new WebClient();
  
  DefaultCredentialsProvider creds = new DefaultCredentialsProvider();
  
  // Set some example credentials
  creds.addCredentials("usr", "pwd");
  
  // And now add the provider to the webClient instance
  webClient.setCredentialsProvider(creds);
  
  webClient.getPage("&lt;some url&gt;")
  </code></pre>
  
  <p>I also tried stuffing the credentials in a WebRequest object and passing that to the <code>webClient.getPage</code> method.</p>
  
  <p>But on the server I don't get an authentication header. I suspect the WebClient only sends the authentication header if it get explicitly asked for it by the server, which never happens.</p>
  
  <p>So the question is how can I make the WebClient send the Authentication header on every request, including the first one?</p>