public static void main(String[] args) throws IOException {
SSLSocket sslSocket = (SSLSocket) SSLSocketFactory.getDefault().createSocket("oc.our-web.org", 443);
// String[] supportedCipherSuites = sslSocket.getSupportedCipherSuites();
// sslSocket.setEnabledCipherSuites(supportedCipherSuites);
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(sslSocket.getInputStream()));
BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(sslSocket.getOutputStream(), StandardCharsets.UTF_8));
// for (String s : Main.restrictedHeaderSet) {
// bufferedWriter.write(s);
// }
bufferedWriter.write("GET / HTTP/1.1\r\n");
bufferedWriter.write("Host: "+"oc.our-web.org"+"\r\n");
bufferedWriter.write("\r\n");
bufferedWriter.flush();
new Thread(() -> {
while (true) {
String line = null;
try {
if ((line = bufferedReader.readLine()) == null) {
break;
}
} catch (IOException e) {
e.printStackTrace();
System.exit(-1);
}
System.out.println(line);
}
}).start();
}
SSLSocket获取网页数据
最新推荐文章于 2024-09-08 11:09:43 发布