okio.BufferedSource.readHexadecimalUnsignedLong()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(7.1k)|赞(0)|评价(0)|浏览(464)

本文整理了Java中okio.BufferedSource.readHexadecimalUnsignedLong()方法的一些代码示例,展示了BufferedSource.readHexadecimalUnsignedLong()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BufferedSource.readHexadecimalUnsignedLong()方法的具体详情如下:
包路径:okio.BufferedSource
类名称:BufferedSource
方法名:readHexadecimalUnsignedLong

BufferedSource.readHexadecimalUnsignedLong介绍

[英]Reads a long form this source in hexadecimal form (i.e., as a string in base 16). This will iterate until a non-hexadecimal character is found.
[中]以十六进制形式读取此源的长格式(即以16进制为基数的字符串)。这将迭代,直到找到非十六进制字符。

代码示例

代码示例来源:origin: square/okhttp

private void readChunkSize() throws IOException {
 // Read the suffix of the previous chunk.
 if (bytesRemainingInChunk != NO_CHUNK_YET) {
  source.readUtf8LineStrict();
 }
 try {
  bytesRemainingInChunk = source.readHexadecimalUnsignedLong();
  String extensions = source.readUtf8LineStrict().trim();
  if (bytesRemainingInChunk < 0 || (!extensions.isEmpty() && !extensions.startsWith(";"))) {
   throw new ProtocolException("expected chunk size and optional extensions but was \""
     + bytesRemainingInChunk + extensions + "\"");
  }
 } catch (NumberFormatException e) {
  throw new ProtocolException(e.getMessage());
 }
 if (bytesRemainingInChunk == 0L) {
  hasMoreChunks = false;
  trailers = readHeaders();
  HttpHeaders.receiveHeaders(client.cookieJar(), url, trailers);
  endOfInput(true, null);
 }
}

代码示例来源:origin: com.squareup.okhttp3/okhttp

private void readChunkSize() throws IOException {
 // Read the suffix of the previous chunk.
 if (bytesRemainingInChunk != NO_CHUNK_YET) {
  source.readUtf8LineStrict();
 }
 try {
  bytesRemainingInChunk = source.readHexadecimalUnsignedLong();
  String extensions = source.readUtf8LineStrict().trim();
  if (bytesRemainingInChunk < 0 || (!extensions.isEmpty() && !extensions.startsWith(";"))) {
   throw new ProtocolException("expected chunk size and optional extensions but was \""
     + bytesRemainingInChunk + extensions + "\"");
  }
 } catch (NumberFormatException e) {
  throw new ProtocolException(e.getMessage());
 }
 if (bytesRemainingInChunk == 0L) {
  hasMoreChunks = false;
  trailers = readHeaders();
  HttpHeaders.receiveHeaders(client.cookieJar(), url, trailers);
  endOfInput(true, null);
 }
}

代码示例来源:origin: square/okio

private void assertLongHexString(String s, long expected) throws IOException {
 sink.writeUtf8(s);
 sink.emit();
 long actual = source.readHexadecimalUnsignedLong();
 assertEquals(s + " --> " + expected, expected, actual);
}

代码示例来源:origin: square/okio

@Test public void longHexStringTooShortThrows() throws IOException {
 try {
  sink.writeUtf8(" ");
  sink.emit();
  source.readHexadecimalUnsignedLong();
  fail();
 } catch (NumberFormatException e) {
  assertEquals("Expected leading [0-9a-fA-F] character but was 0x20", e.getMessage());
 }
}

代码示例来源:origin: square/okio

@Test public void longHexStringTooLongThrows() throws IOException {
 try {
  sink.writeUtf8("fffffffffffffffff");
  sink.emit();
  source.readHexadecimalUnsignedLong();
  fail();
 } catch (NumberFormatException e) {
  assertEquals("Number too large: fffffffffffffffff", e.getMessage());
 }
}

代码示例来源:origin: square/okio

@Test public void longHexEmptySourceThrows() throws IOException {
 try {
  sink.writeUtf8("");
  sink.emit();
  source.readHexadecimalUnsignedLong();
  fail();
 } catch (EOFException expected) {
 }
}

代码示例来源:origin: square/okio

@Test public void longHexStringAcrossSegment() throws IOException {
 sink.writeUtf8(repeat('a', SEGMENT_SIZE - 8)).writeUtf8("FFFFFFFFFFFFFFFF");
 sink.emit();
 source.skip(SEGMENT_SIZE - 8);
 assertEquals(-1, source.readHexadecimalUnsignedLong());
}

代码示例来源:origin: duzechao/OKHttpUtils

private void readChunkSize() throws IOException {
 // Read the suffix of the previous chunk.
 if (bytesRemainingInChunk != NO_CHUNK_YET) {
  source.readUtf8LineStrict();
 }
 try {
  bytesRemainingInChunk = source.readHexadecimalUnsignedLong();
  String extensions = source.readUtf8LineStrict().trim();
  if (bytesRemainingInChunk < 0 || (!extensions.isEmpty() && !extensions.startsWith(";"))) {
   throw new ProtocolException("expected chunk size and optional extensions but was \""
     + bytesRemainingInChunk + extensions + "\"");
  }
 } catch (NumberFormatException e) {
  throw new ProtocolException(e.getMessage());
 }
 if (bytesRemainingInChunk == 0L) {
  hasMoreChunks = false;
  httpEngine.receiveHeaders(readHeaders());
  endOfInput(true);
 }
}

代码示例来源:origin: huxq17/SwipeCardsView

private void readChunkSize() throws IOException {
 // Read the suffix of the previous chunk.
 if (bytesRemainingInChunk != NO_CHUNK_YET) {
  source.readUtf8LineStrict();
 }
 try {
  bytesRemainingInChunk = source.readHexadecimalUnsignedLong();
  String extensions = source.readUtf8LineStrict().trim();
  if (bytesRemainingInChunk < 0 || (!extensions.isEmpty() && !extensions.startsWith(";"))) {
   throw new ProtocolException("expected chunk size and optional extensions but was \""
     + bytesRemainingInChunk + extensions + "\"");
  }
 } catch (NumberFormatException e) {
  throw new ProtocolException(e.getMessage());
 }
 if (bytesRemainingInChunk == 0L) {
  hasMoreChunks = false;
  httpEngine.receiveHeaders(readHeaders());
  endOfInput();
 }
}

代码示例来源:origin: huxq17/tractor

private void readChunkSize() throws IOException {
 // Read the suffix of the previous chunk.
 if (bytesRemainingInChunk != NO_CHUNK_YET) {
  source.readUtf8LineStrict();
 }
 try {
  bytesRemainingInChunk = source.readHexadecimalUnsignedLong();
  String extensions = source.readUtf8LineStrict().trim();
  if (bytesRemainingInChunk < 0 || (!extensions.isEmpty() && !extensions.startsWith(";"))) {
   throw new ProtocolException("expected chunk size and optional extensions but was \""
     + bytesRemainingInChunk + extensions + "\"");
  }
 } catch (NumberFormatException e) {
  throw new ProtocolException(e.getMessage());
 }
 if (bytesRemainingInChunk == 0L) {
  hasMoreChunks = false;
  httpEngine.receiveHeaders(readHeaders());
  endOfInput();
 }
}

代码示例来源:origin: com.github.ljun20160606/okhttp

private void readChunkSize() throws IOException {
 // Read the suffix of the previous chunk.
 if (bytesRemainingInChunk != NO_CHUNK_YET) {
  source.readUtf8LineStrict();
 }
 try {
  bytesRemainingInChunk = source.readHexadecimalUnsignedLong();
  String extensions = source.readUtf8LineStrict().trim();
  if (bytesRemainingInChunk < 0 || (!extensions.isEmpty() && !extensions.startsWith(";"))) {
   throw new ProtocolException("expected chunk size and optional extensions but was \""
     + bytesRemainingInChunk + extensions + "\"");
  }
 } catch (NumberFormatException e) {
  throw new ProtocolException(e.getMessage());
 }
 if (bytesRemainingInChunk == 0L) {
  hasMoreChunks = false;
  HttpHeaders.receiveHeaders(client.cookieJar(), url, readHeaders());
  endOfInput(true, null);
 }
}

代码示例来源:origin: apache/servicemix-bundles

private void readChunkSize() throws IOException {
 // Read the suffix of the previous chunk.
 if (bytesRemainingInChunk != NO_CHUNK_YET) {
  source.readUtf8LineStrict();
 }
 try {
  bytesRemainingInChunk = source.readHexadecimalUnsignedLong();
  String extensions = source.readUtf8LineStrict().trim();
  if (bytesRemainingInChunk < 0 || (!extensions.isEmpty() && !extensions.startsWith(";"))) {
   throw new ProtocolException("expected chunk size and optional extensions but was \""
     + bytesRemainingInChunk + extensions + "\"");
  }
 } catch (NumberFormatException e) {
  throw new ProtocolException(e.getMessage());
 }
 if (bytesRemainingInChunk == 0L) {
  hasMoreChunks = false;
  HttpHeaders.receiveHeaders(client.cookieJar(), url, readHeaders());
  endOfInput(true, null);
 }
}

相关文章

微信公众号

最新文章

更多