$ cat TestClient.java
import static java.lang.System.*;
import java.io.*;
import java.net.*;
import java.util.*;
public class TestClient {
private static final String CRLF = "\r\n";
public static void main(String... args) throws IOException {
Socket socket = new Socket("127.0.0.1", 8080);
OutputStreamWriter out = new OutputStreamWriter(socket.getOutputStream());
out.write("GET");
out.write(" ");
out.write("/helloworld-rs/rest/matrix/example;");
out.write("foo=bar;");
out.write("hoge=fu");
out.flush();
sleep(100);
out.write("ga;");
out.write("test=te");
out.flush();
sleep(100);
out.write("st;");
out.write(" HTTP/1.1");
out.write(CRLF);
out.write("User-Agent: TestClient" + CRLF);
out.write("Host: 127.0.0.1:8080" + CRLF);
out.write(CRLF);
out.flush();
try (BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));) {
System.out.println("response from server:");
br.lines().forEach(text -> {
System.out.println(text);
});
}
}
private static void sleep(long millis) {
try {
Thread.sleep(millis);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
$ javac TestClient.java
$ java TestClient
response from server:
HTTP/1.1 200 OK
Connection: keep-alive
Content-Type: application/octet-stream
Content-Length: 115
Date: Thu, 05 Jan 2023 06:18:56 GMT
Matrix Param List:<br/>
Path: example, Matrix Params {st=[null], test=[te], hoge=[fu], foo=[bar], ga=[null]}<br/>