title: Referer in URLConnection doesn't work
body: <p>I would like to fetch a html page with post method. First I use HttpClient, it doesn't give the right response,  then I add <code>Header</code> with a <code>Referer</code>, it works well but too slow. So I plan to use URLConnection, I also add <code>Referer</code> to the <code>Header</code>, this time it doesn't return what I want.</p>
  
  <p>HttpClient:</p>
  
  <pre><code>httpclient = new DefaultHttpClient();  
              HttpPost httppost = new HttpPost(WhutGlobal.URL_HEADER_STR + "xscj_gc.aspx?xh=" + WhutGlobal.USER_ID + "&amp;xm=" + WhutGlobal.USER_NAME + "&amp;gnmkdm=N121605");
              try {
                  httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
                  httppost.setHeader("Referer", WhutGlobal.URL_HEADER_STR + "xscj_gc.aspx?xh=" + WhutGlobal.USER_ID + "&amp;xm=" + WhutGlobal.USER_NAME + "&amp;gnmkdm=N121605");
                  HttpResponse response = httpclient.execute(httppost);
                  HttpEntity entity = response.getEntity();
                  InputStream is = entity.getContent();
                  BufferedInputStream bis = new BufferedInputStream(is);
                  byte  bytearray[] = new  byte[800000];
                   int current= -1;
                   int i=0;  
                   while((current=bis.read())!=-1) {
                       bytearray[i] =(byte) current;
                        i++;
                 }
                html = new String (bytearray,"GB2312");
              } catch (ClientProtocolException e) {
                  // TODO Auto-generated catch block
              } catch (IOException e) {
                  // TODO Auto-generated catch block
              }
  </code></pre>
  
  <p>URLConnection:</p>
  
  <pre><code> URL url = new URL(WhutGlobal.URL_HEADER_STR + "xscj_gc.aspx?xh=" + WhutGlobal.USER_ID + "&amp;xm=" + WhutGlobal.USER_NAME + "&amp;gnmkdm=N121605");
           HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
           urlConnection.setDoOutput(true);
           urlConnection.setDoInput(true);
           urlConnection.setRequestMethod("POST");
           urlConnection.setRequestProperty("Connection", "Keep-Alive");
           urlConnection.setRequestProperty("Accept-Encoding", "gzip");
           urlConnection.setRequestProperty("Referer", WhutGlobal.URL_HEADER_STR + "xscj_gc.aspx?xh=" + WhutGlobal.USER_ID + "&amp;xm=" + WhutGlobal.USER_NAME + "&amp;gnmkdm=N121605");
           DataOutputStream wr = new DataOutputStream (
                     urlConnection.getOutputStream ());
           wr.writeBytes (urlParameters);
           wr.flush ();
           wr.close ();
  </code></pre>