我目前正在使用 BufferedReader 监听端口,例如:
ServerSocket ss = new ServerSocket(2346);
Socket s = ss.accept();
BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream()));
while(true){
inputLine = in.readLine();
if(inputLine==null)
break;
}
现在我得到了所有的标题和所有的东西,比如:
POST /record HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: text/xml;charset=UTF-8
SOAPAction: ""
Content-Length: 1969
Host: localhost:2346
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
<S:Envelope xmlns:S="http://www.w3.org/2003/05/soap-envelope">...
问题是我只需要 POST 请求的内容(上面的最后一行),那么是否有一个 Java 解析器可以做到这一点。在我对套接字的请求中,我需要提供一个额外的空行以允许正确读取它。有解决方案吗?
谢谢