title: Why does URLConnection.getInputStream() not include the HTTP response headers?
body: <p>I use this.</p>
  
  <pre><code>public static final String LOGIN_URL = "http://www.icourse163.org/passport/reg/icourseLogin.do";
  
  public static void loginSimulation() throws IOException {
      URL loginUrl = new URL(LOGIN_URL);
      URLConnection connection = loginUrl.openConnection();
      connection.setRequestProperty("User-Agent",
              "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36");
      connection.setRequestProperty("Accept",
              "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8");
      connection.setRequestProperty("Accept-Language", "zh-CN,zh;q=0.8");
      connection.setRequestProperty("Connection", "keep-alive");
      connection.setRequestProperty("Referer", "http://www.icourse163.org/member/logout.htm");
      connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
      connection.setDoOutput(true);
  
      PrintWriter loginDataWriter = new PrintWriter(connection.getOutputStream());
  
      String loginData = "returnUrl=aHR0cDovL2ljb3Vyc2UxNjMub3JnLw%3D%3D&amp;failUrl=aHR0cDovL3d3dy5pY291cnNlMTYzLm9yZy9tZW1iZXIvbG9naW4uaHRtP2VtYWlsRW5jb2RlZD1PVGM1TnpJME9EZ3lRSEZ4TG1OdmJRPT0%3D&amp;savelogin=false&amp;oauthType=&amp;username=979724882%40qq.com";
      loginDataWriter.print(loginData);
      loginDataWriter.flush();
  
  
  
      BufferedReader reader = new BufferedReader(
              new InputStreamReader(connection.getInputStream()));
      StringBuilder builder = new StringBuilder();
      String line;
      while ((line = reader.readLine()) != null){
          builder.append(line);
      }
  </code></pre>
  
  <p>But the <code>builder.toString</code> did not have any information about the response headers? I think there is a pipe between my client and the server. So all of the response should come through this pipe (including the response headers, response content etc). But the result is not. Why?</p>