title: HTTPS GET / HTTP/1.1 request through Java socket
body: <p>I am trying to request an HTTPS page using Java socket programming. The code I use is </p>
  
  <pre><code>PrintWriter s_out = null;
  
  s_out = new PrintWriter(socketData.getOutputStream(), true);
  
  String message = "GET / HTTP/1.1\r\nHost:stackoverflow.com\r\n";
  
  s_out.println(message);
  </code></pre>
  
  <p>The response was:</p>
  
  <pre><code>HTTP/1.1301MovedPermanentlyLocation:https://stackoverflow.com/X-Request-Guid:b49f01e7-8c3f-4276-b9fe-e325684f0f88Content-Length:143Accept-Ranges:bytesDate:Mon,31Jul201707:15:48GMTVia:1.1varnishConnection:keep-aliveX-Served-By:cache-sin18033-SINX-Cache:MISSX-Cache-Hits:0X-Timer:S1501485348.066340,VS0,VE366Vary:Fastly-SSLX-DNS-Prefetch-Control:offSet-Cookie:prov=929f70a3-e93d-2948-7098-74624f7c4e3c;domain=.stackoverflow.com;expires=Fri,01-Jan-205500:00:00GMT;path=/;HttpOnly&lt;html&gt;&lt;head&gt;&lt;title&gt;Objectmoved&lt;/title&gt;&lt;/head&gt;&lt;body&gt;&lt;h2&gt;Objectmovedto&lt;ahref="https://stackoverflow.com/"&gt;here&lt;/a&gt;.&lt;/h2&gt;&lt;/body&gt;&lt;/html&gt;
  </code></pre>
  
  <p>I don't know the syntax to request</p>
  
  <p><a href="https://stackoverflow.com">https://stackoverflow.com</a> in <code>GET / HTTP/1.1\r\nHost:stackoverflow.com\r\n</code>, </p>
  
  <p>Can you please suggest what is the syntax to invoke https page?</p>
  
  <p>Thanks.</p>