打开套接字并发送请求后,立即从InputStreamReader中的第三方系统得到了请求。通过while循环响应逐行读取,并在同一秒内读取标头,并在响应主体之前的最后一行读取空白行。但是系统在读取该空行后将等待30秒。
String path = "/System";
wr = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
wr.write("POST " + path + " HTTP/1.1\r\n");
wr.write("content-type: text/xml\r\n");
wr.write("\r\n");
wr.write(data);
wr.flush();
BufferedReader rd=new BufferedReader(newInputStreamReader(socket.getInputStream()));
String line;
while ((line = rd.readLine()) != null) {
if (line != null && line.startsWith("<?xml")) {
startreading = true;
}
if (startreading) {
response += line;
}
}
wr.close();
rd.close();
socket.close();
//Response
[2019-05-14 18:59:12 INFO-SUBAPP SendRequest:91] response packet : java.io.BufferedReader@6d613c74
[2019-05-14 18:59:12 INFO-SUBAPP SendRequest:93] bufferreader not null
[2019-05-14 18:59:12 INFO-SUBAPP SendRequest:100] line : HTTP/1.1 200 OK
[2019-05-14 18:59:12 INFO-SUBAPP SendRequest:102] line : Date: Tue, 14 May 2019 14:53:49 GMT
[2019-05-14 18:59:12 INFO-SUBAPP SendRequest:104] line : X-Powered-By: abc
[2019-05-14 18:59:12 INFO-SUBAPP SendRequest:106] line : Server: abcbcbcbbc.asdsadas
[2019-05-14 18:59:12 INFO-SUBAPP SendRequest:108] line : Set-Cookie: JSESSIONID=e38jasdsadsadsada1wyf9q;Path=/
[2019-05-14 18:59:12 INFO-SUBAPP SendRequest:110] line : Expires: Thu, 01 Jan 1970 00:00:00 GMT
[2019-05-14 18:59:12 INFO-SUBAPP SendRequest:112] line : Content-Type: text/xml
[2019-05-14 18:59:12 INFO-SUBAPP SendRequest:114] line : Content-Length: ***
[2019-05-14 18:59:12 INFO-SUBAPP SendRequest:116] line :
[2019-05-14 18:59:42 INFO-SUBAPP SendRequest:118] line : <?xml version="1.0" encoding="UTF-8"?><methodResponse><params><param><value>