title: Android HttpUrlConnection passing header params
body: <p>I searched other topics and there were some answers but I didn't succeed to solve my problem.
  I have this code and I want to add "Referer" to my http headers.
  After using setRequestProperty method, I log the results in Logcat but I don't see referer in the output. what am I doing wrong?</p>
  
  <pre><code>URL url = new URL(uri);
  HttpURLConnection con = (HttpURLConnection) url.openConnection();
  con.setRequestProperty("Referer", "http://www.example.com");
  for(int i=0;con.getHeaderFieldKey(i)!=null;i++){
      String headerName = con.getHeaderFieldKey(i);
      String headerValue = con.getHeaderField(i);
      Log.d("Header", headerName + ": " + headerValue);
  }
  </code></pre>
  
  <p>I also have another code which is not working either:</p>
  
  <pre><code>URL url = new URL(uri);
  HttpURLConnection con = (HttpURLConnection) url.openConnection();
  String IRNIC = cookies.get("IRNIC");
  String ROUTEID = cookies.get("ROUTEID");
  String myCookies = "IRNIC="+IRNIC+"; ROUTEID="+ROUTEID;
  con.setRequestProperty("Cookie", myCookies);
  for(int i=0;con.getHeaderFieldKey(i)!=null;i++){
      String headerName = con.getHeaderFieldKey(i);
      String headerValue = con.getHeaderField(i);
      Log.d("Header", headerName + ": " + headerValue);
  }
  </code></pre>
  
  <p>For the first code, I don't see referer in the output and also for the second code, I don't see cookies too.
  So it seems setRequestProperty is not working!
  Thanks in advance.</p>
  
  <p><strong>EDIT:</strong> I can see headers in the output but not the ones I added via setRequestProperty method. so the if code is working.</p>