mirror of
https://github.com/corda/corda.git
synced 2025-01-17 02:09:50 +00:00
make Sockets test Java6-compilable, make it more generic, and move it to 'extra'
This commit is contained in:
parent
45ee25f68c
commit
c3bbe555be
@ -1,3 +1,5 @@
|
||||
package extra;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
@ -15,11 +17,12 @@ public class Sockets {
|
||||
*/
|
||||
public static void main(String[] args) throws UnknownHostException,
|
||||
IOException {
|
||||
System.out.print("Requesting...\n");
|
||||
try (Socket sock = new Socket("www.google.com", 80)) {
|
||||
System.out.print("Requesting... " + args[0] + "\n");
|
||||
Socket sock = new Socket(args[0], 80);
|
||||
try {
|
||||
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(sock.getOutputStream()));
|
||||
String request = "GET /?gws_rd=cr HTTP/1.1\r\n"
|
||||
+ "Host: www.google.com\r\n" + "Accept: */*\r\n"
|
||||
+ "Host: " + args[0] + "\r\n" + "Accept: */*\r\n"
|
||||
+ "User-Agent: Java\r\n" + "Connection: close\r\n" + "\r\n";
|
||||
bw.write(request);
|
||||
bw.flush();
|
||||
@ -30,6 +33,7 @@ public class Sockets {
|
||||
System.out.println(read);
|
||||
}
|
||||
bw.close();
|
||||
} finally {
|
||||
sock.close();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user