+
95
-

回答

还可以使用fcgi4j这个java库

github地址https://github.com/Happyr/fcgi4j

使用方式

//create FastCGI connection
FCGIConnection connection = FCGIConnection.open();
connection.connect(new InetSocketAddress("localhost", 5672));

connection.beginRequest("/var/www/foobar.php");
connection.setRequestMethod("POST");

byte[] postData = "hello=world".getBytes();

//set contentLength, it's important
connection.setContentLength(postData.length);
connection.write(ByteBuffer.wrap(postData));

//print response headers
Map<String, String> responseHeaders = connection.getResponseHeaders();
for (String key : responseHeaders.keySet()) {
System.out.println("HTTP HEADER: " + key + "->" + responseHeaders.get(key));
}

//read response data
ByteBuffer buffer = ByteBuffer.allocate(10240);
connection.read(buffer);
buffer.flip();

byte[] data = new byte[buffer.remaining()];
buffer.get(data);

System.out.println(new String(data));

//close the connection
connection.close();


网友回复

我知道答案,我要回答