Пример #1
0
 private void readGoAway(Handler handler, int flags, int length, int streamId)
     throws IOException {
   if (length < 8) throw ioException("TYPE_GOAWAY length < 8: %s", length);
   int lastStreamId = in.readInt();
   int errorCodeInt = in.readInt();
   int opaqueDataLength = length - 8;
   ErrorCode errorCode = ErrorCode.fromHttp2(errorCodeInt);
   if (errorCode == null) {
     throw ioException("TYPE_RST_STREAM unexpected error code: %d", errorCodeInt);
   }
   if (Util.skipByReading(in, opaqueDataLength) != opaqueDataLength) {
     throw new IOException("TYPE_GOAWAY opaque data was truncated");
   }
   handler.goAway(lastStreamId, errorCode);
 }
Пример #2
0
 private void readGoAway(Handler handler, int length, byte flags, int streamId)
     throws IOException {
   if (length < 8) throw ioException("TYPE_GOAWAY length < 8: %s", length);
   if (streamId != 0) throw ioException("TYPE_GOAWAY streamId != 0");
   int lastStreamId = source.readInt();
   int errorCodeInt = source.readInt();
   int opaqueDataLength = length - 8;
   ErrorCode errorCode = ErrorCode.fromHttp2(errorCodeInt);
   if (errorCode == null) {
     throw ioException("TYPE_GOAWAY unexpected error code: %d", errorCodeInt);
   }
   ByteString debugData = EMPTY;
   if (opaqueDataLength > 0) { // Must read debug data in order to not corrupt the connection.
     debugData = source.readByteString(opaqueDataLength);
   }
   handler.goAway(lastStreamId, errorCode, debugData);
 }