Having some problems with the following code:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;
class Main {
public static void main(String args[]) {
try {
Socket s = new Socket("ark.intel.com", 80);
PrintWriter out = new PrintWriter(s.getOutputStream());
out.write("GET / HTTP/1.1\r\n"
+ "Host: ark.intel.com\r\n"
+ "Connection: keep-alive\r\n"
+ "User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36\r\n"
+ "Accept: text/html"
+ "\r\n");
out.flush();
BufferedReader read = new BufferedReader(new InputStreamReader(s.getInputStream()));
String line;
String data = "";
while ((line = read.readLine()) != null) {
data += line;
System.out.println(line);
} read.close();
} catch (Exception error) {}
}
}
i keep getting
HTTP/1.0 408 Request Time-out Server: AkamaiGHost Mime-Version: 1.0 Date: Tue, 06 Feb 2018 11:43:41 GMT Content-Type: text/html Content-Length: 218 Expires: Tue, 06 Feb 2018 11:43:41 GMT
<HTML><HEAD>
<TITLE>Request Timeout</TITLE>
</HEAD><BODY>
<H1>Request Timeout</H1>
The server timed out while waiting for the browser's request.<P>
Reference #2.403b3717.1517917421.0
</BODY></HTML>
any idea on how to fix this?
Edit: The host ark.intel.com is using HTTPS, i need to find a way to send the requests over HTTPS rather then HTTP.