!7 p { S hostname = "ai1.lol", S subURL = "/1008855/raw"; int port = 80; Socket socket = new Socket(hostname, port); BufferedReader reader = null; PrintWriter writer = null; try { writer = new PrintWriter(new OutputStreamWriter(socket.getOutputStream(), "ASCII")); writer.println("HEAD " + subURL + " HTTP/1.1"); writer.println("Host: " + hostname); writer.println("Accept: */*"); writer.println("User-Agent: Java"); // Be honest. writer.println(""); // Important, else the server will expect that there's more into the request. writer.flush(); reader = new BufferedReader(new InputStreamReader(socket.getInputStream(), "ASCII")); for (String line; (line = reader.readLine()) != null;) { if (line.isEmpty()) break; // Stop when headers are completed. We're not interested in all the HTML. print("> " + line); } } finally { if (reader != null) pcall { reader.close(); } if (writer != null) pcall { writer.close(); } if (socket != null) pcall { socket.close(); } } }