title: Send HTTP request manually via socket
body: <p>When I send a normal HTTP request via a socket, the server does not respond with an OK response. I copied the HTTP header from Firefox. Here is the code:</p>
  
  <pre><code>Socket s = new Socket(InetAddress.getByName("stackoverflow.com"), 80);
  PrintWriter pw = new PrintWriter(s.getOutputStream());
  pw.print("GET / HTTP/1.1");
  pw.print("Host: stackoverflow.com");
  pw.flush();
  BufferedReader br = new BufferedReader(new InputStreamReader(s.getInputStream()));
  String t;
  while((t = br.readLine()) != null) System.out.println(t);
  br.close();
  </code></pre>
  
  <p>However, here is the response I received:</p>
  
  <pre><code>HTTP/1.0 408 Request Time-out
  Cache-Control: no-cache
  Connection: close
  Content-Type: text/html
  
  &lt;html&gt;&lt;body&gt;&lt;h1&gt;408 Request Time-out&lt;/h1&gt;
  Your browser didn't send a complete request in time.
  &lt;/body&gt;&lt;/html&gt;
  </code></pre>
  
  <p>I know that I can do this by using <code>URL.openStream()</code>, but why doesn't the server identify the HTTP request when I send it manually?</p>