title: HtmlUnit: Request website from server in a specific language
body: <p><strong>I am looking for a clean/simple way in HtmlUnit to request a webpage from a server in a specific language.</strong></p>
  
  <p>To do this i have been trying to request "bankofamerica.com" for their homepage in spanish instead of english.</p>
  
  <p>This is what i have done so far:</p>
  
  <p>I tried to set "Accept-Language" header to "es" in the Http request. I did this using:</p>
  
  <pre><code>myWebClient.addRequestHeader("Accept-Language" , "es");
  </code></pre>
  
  <p>It did not work. I then created a web request with the following code:</p>
  
  <pre><code>URL myUrl = new URL("https://www.bankofamerica.com/");
  WebRequest myRequest = new WebRequest(myUrl);
  myRequest.setAdditionalHeader("Accept-Language", "es");
  HtmlPage aPage = myWebClient.getPage(myRequest);
  </code></pre>
  
  <p>Since this failed too i printed out the request object for this url , to check if these headers are being set.</p>
  
  <pre><code>[&lt;url="https://www.bankofamerica.com/", GET, EncodingType[name=application/x-www-form-urlencoded], [], {Accept-Language=es, Accept-Encoding=gzip, deflate, Accept=*/*}, null&gt;]
  </code></pre>
  
  <p>So the server is being requested for a spanish page but in response its sending the homepage in english (the response header has the value of Content-Language set to en-US)</p>
  
  <p>I did find a hack to retrieve the BOA page in spanish. I visited this page and used the chrome developer tool to get the cookie value from the request 
  header. I used this value to do the following:</p>
  
  <pre><code> myRequest.setAdditionalHeader("Cookie", "TLTSID= ........._LOCALE_COOKIE=es-US; CONTEXT=es_US; INTL_LANG=es_US; LANG_COOKIE=es_US; hp_pf_anon=anon=((ct=+||st=+||fn=+||zc=+||lang=es_US));..........1870903; throttle_value=43");
  </code></pre>
  
  <p>I am guessing the answer lies somewhere here. </p>
  
  <p><strong>Here lies my next question. If i am writing a script to retrieve 100 different websites in Spanish (ie Assuming they all have their pages in the spanish) . Is there a clean way in HtmlUnit to accomplish this.</strong> </p>
  
  <p>(If cookies is indeed a solution then to create them in htmlunit you need to specify the domain name. One would have to then create cookies for each of the 100 sites. As far as i know there is no way in HtmlUnit to do something like: </p>
  
  <p>Cookie langCookie = new Cookie("All Domains","LANG_COOKIE","es_US");
  myWebClient.getCookieManager().addCookie(langCookie);)</p>
  
  <p><strong>NOTE:</strong> I am using HtmlUnit 2.12 and setting BrowserVersion.CHROME in the webclient</p>
  
  <p>Thanks.</p>