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;
  }
Пример #2
0
 @Override
 public String readLine() {
   try {
     return input.readLine();
   } catch (IOException e) {
     throw new IllegalStateException(e);
   }
 }
Пример #3
0
  @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);
    }
  }
Пример #4
0
 public String readLine() throws IOException {
   return dataInput.readLine();
 }
Пример #5
0
 @Override
 public void readFields(DataInput in) throws IOException {
   this.errorValue = in.readLine();
 }