MCPcopy Create free account
hub / github.com/M66B/FairEmail / readResponse

Method readResponse

app/src/main/java/com/sun/mail/pop3/Protocol.java:1206–1252  ·  view source on GitHub ↗

Read the response to a command.

()

Source from the content-addressed store, hash-verified

1204 * Read the response to a command.
1205 */
1206 private Response readResponse() throws IOException {
1207 String line = null;
1208 try {
1209 line = input.readLine();
1210 } catch (InterruptedIOException iioex) {
1211 /*
1212 * If we get a timeout while using the socket, we have no idea
1213 * what state the connection is in. The server could still be
1214 * alive, but slow, and could still be sending data. The only
1215 * safe way to recover is to drop the connection.
1216 */
1217 try {
1218 socket.close();
1219 } catch (IOException cex) { }
1220 throw new EOFException(iioex.getMessage());
1221 } catch (SocketException ex) {
1222 /*
1223 * If we get an error while using the socket, we have no idea
1224 * what state the connection is in. The server could still be
1225 * alive, but slow, and could still be sending data. The only
1226 * safe way to recover is to drop the connection.
1227 */
1228 try {
1229 socket.close();
1230 } catch (IOException cex) { }
1231 throw new EOFException(ex.getMessage());
1232 }
1233
1234 if (line == null) {
1235 traceLogger.finest("<EOF>");
1236 throw new EOFException("EOF on socket");
1237 }
1238 Response r = new Response();
1239 if (line.startsWith("+OK"))
1240 r.ok = true;
1241 else if (line.startsWith("+ ")) {
1242 r.ok = true;
1243 r.cont = true;
1244 } else if (line.startsWith("-ERR"))
1245 r.ok = false;
1246 else
1247 throw new IOException("Unexpected response: " + line);
1248 int i;
1249 if ((i = line.indexOf(' ')) >= 0)
1250 r.data = line.substring(i + 1);
1251 return r;
1252 }
1253
1254 /**
1255 * Issue a POP3 command that expects a multi-line response.

Callers 4

loginMethod · 0.95
retrMethod · 0.95
simpleCommandMethod · 0.95
multilineCommandMethod · 0.95

Calls 5

finestMethod · 0.80
indexOfMethod · 0.80
getMessageMethod · 0.65
readLineMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected