当前位置: 首页>>代码示例>>Java>>正文


Java Util.skipByReading方法代码示例

本文整理汇总了Java中com.squareup.okhttp.internal.Util.skipByReading方法的典型用法代码示例。如果您正苦于以下问题:Java Util.skipByReading方法的具体用法?Java Util.skipByReading怎么用?Java Util.skipByReading使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.squareup.okhttp.internal.Util的用法示例。


在下文中一共展示了Util.skipByReading方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: data

import com.squareup.okhttp.internal.Util; //导入方法依赖的package包/类
@Override public void data(boolean inFinished, int streamId, InputStream in, int length)
    throws IOException {
  SpdyStream dataStream = getStream(streamId);
  if (dataStream == null) {
    writeSynResetLater(streamId, ErrorCode.INVALID_STREAM);
    Util.skipByReading(in, length);
    return;
  }
  dataStream.receiveData(in, length);
  if (inFinished) {
    dataStream.receiveFin();
  }
}
 
开发者ID:aabognah,项目名称:LoRaWAN-Smart-Parking,代码行数:14,代码来源:SpdyConnection.java

示例2: readGoAway

import com.squareup.okhttp.internal.Util; //导入方法依赖的package包/类
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);
}
 
开发者ID:aabognah,项目名称:LoRaWAN-Smart-Parking,代码行数:16,代码来源:Http20Draft06.java

示例3: receive

import com.squareup.okhttp.internal.Util; //导入方法依赖的package包/类
void receive(InputStream in, int byteCount) throws IOException {
  assert (!Thread.holdsLock(SpdyStream.this));

  if (byteCount == 0) {
    return;
  }

  int pos;
  int limit;
  int firstNewByte;
  boolean finished;
  boolean flowControlError;
  synchronized (SpdyStream.this) {
    finished = this.finished;
    pos = this.pos;
    firstNewByte = this.limit;
    limit = this.limit;
    flowControlError = byteCount > buffer.length - available();
  }

  // If the peer sends more data than we can handle, discard it and close the connection.
  if (flowControlError) {
    Util.skipByReading(in, byteCount);
    closeLater(ErrorCode.FLOW_CONTROL_ERROR);
    return;
  }

  // Discard data received after the stream is finished. It's probably a benign race.
  if (finished) {
    Util.skipByReading(in, byteCount);
    return;
  }

  // Fill the buffer without holding any locks. First fill [limit..buffer.length) if that
  // won't overwrite unread data. Then fill [limit..pos). We can't hold a lock, otherwise
  // writes will be blocked until reads complete.
  if (pos < limit) {
    int firstCopyCount = Math.min(byteCount, buffer.length - limit);
    Util.readFully(in, buffer, limit, firstCopyCount);
    limit += firstCopyCount;
    byteCount -= firstCopyCount;
    if (limit == buffer.length) {
      limit = 0;
    }
  }
  if (byteCount > 0) {
    Util.readFully(in, buffer, limit, byteCount);
    limit += byteCount;
  }

  synchronized (SpdyStream.this) {
    // Update the new limit, and mark the position as readable if necessary.
    this.limit = limit;
    if (this.pos == -1) {
      this.pos = firstNewByte;
      SpdyStream.this.notifyAll();
    }
  }
}
 
开发者ID:aabognah,项目名称:LoRaWAN-Smart-Parking,代码行数:60,代码来源:SpdyStream.java

示例4: nextFrame

import com.squareup.okhttp.internal.Util; //导入方法依赖的package包/类
/**
 * Send the next frame to {@code handler}. Returns true unless there are no
 * more frames on the stream.
 */
@Override public boolean nextFrame(Handler handler) throws IOException {
  int w1;
  try {
    w1 = in.readInt();
  } catch (IOException e) {
    return false; // This might be a normal socket close.
  }
  int w2 = in.readInt();

  boolean control = (w1 & 0x80000000) != 0;
  int flags = (w2 & 0xff000000) >>> 24;
  int length = (w2 & 0xffffff);

  if (control) {
    int version = (w1 & 0x7fff0000) >>> 16;
    int type = (w1 & 0xffff);

    if (version != 3) {
      throw new ProtocolException("version != 3: " + version);
    }

    switch (type) {
      case TYPE_SYN_STREAM:
        readSynStream(handler, flags, length);
        return true;

      case TYPE_SYN_REPLY:
        readSynReply(handler, flags, length);
        return true;

      case TYPE_RST_STREAM:
        readRstStream(handler, flags, length);
        return true;

      case TYPE_SETTINGS:
        readSettings(handler, flags, length);
        return true;

      case TYPE_NOOP:
        if (length != 0) throw ioException("TYPE_NOOP length: %d != 0", length);
        handler.noop();
        return true;

      case TYPE_PING:
        readPing(handler, flags, length);
        return true;

      case TYPE_GOAWAY:
        readGoAway(handler, flags, length);
        return true;

      case TYPE_HEADERS:
        readHeaders(handler, flags, length);
        return true;

      case TYPE_WINDOW_UPDATE:
        readWindowUpdate(handler, flags, length);
        return true;

      case TYPE_CREDENTIAL:
        Util.skipByReading(in, length);
        throw new UnsupportedOperationException("TODO"); // TODO: implement

      default:
        throw new IOException("Unexpected frame");
    }
  } else {
    int streamId = w1 & 0x7fffffff;
    boolean inFinished = (flags & FLAG_FIN) != 0;
    handler.data(inFinished, streamId, in, length);
    return true;
  }
}
 
开发者ID:aabognah,项目名称:LoRaWAN-Smart-Parking,代码行数:78,代码来源:Spdy3.java


注:本文中的com.squareup.okhttp.internal.Util.skipByReading方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。