protected boolean consumeHttpResponseHead(DataInput dataInput) throws IOException { String statusLine = dataInput.readLine(); if (!statusLine.equals("HTTP/1.1 200 OK")) { throw new IOException("Error status line: " + statusLine); } boolean forceCloseSocket = false; String line = null; while (((line = dataInput.readLine()) != null) && (line.length() > 0)) { String[] headerKeyValuePair = StringUtil.split(line, CharPool.COLON); String headerName = headerKeyValuePair[0].trim(); headerName = StringUtil.toLowerCase(headerName); if (headerName.equals("connection")) { String headerValue = headerKeyValuePair[1].trim(); headerValue = StringUtil.toLowerCase(headerValue); if (headerValue.equals("close")) { forceCloseSocket = true; } } } return forceCloseSocket; }
@Override public String readLine() { try { return input.readLine(); } catch (IOException e) { throw new IllegalStateException(e); } }
@Override public void readData(DataInput reader) throws IOException { dataMap.clear(); int id; while ((id = reader.readInt()) != 0) { String key = reader.readLine(); DataTagBase tag = getType(id); tag.readData(reader); dataMap.put(key, tag); } }
public String readLine() throws IOException { return dataInput.readLine(); }
@Override public void readFields(DataInput in) throws IOException { this.errorValue = in.readLine(); }