Java Code Examples for com.squareup.okhttp.internal.Util#readAsciiLine()

The following examples show how to use com.squareup.okhttp.internal.Util#readAsciiLine() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HttpTransport.java    From L.TileLayer.Cordova with MIT License 6 votes vote down vote up
private void readChunkSize() throws IOException {
  // read the suffix of the previous chunk
  if (bytesRemainingInChunk != NO_CHUNK_YET) {
    Util.readAsciiLine(in);
  }
  String chunkSizeString = Util.readAsciiLine(in);
  int index = chunkSizeString.indexOf(";");
  if (index != -1) {
    chunkSizeString = chunkSizeString.substring(0, index);
  }
  try {
    bytesRemainingInChunk = Integer.parseInt(chunkSizeString.trim(), 16);
  } catch (NumberFormatException e) {
    throw new ProtocolException("Expected a hex chunk size but was " + chunkSizeString);
  }
  if (bytesRemainingInChunk == 0) {
    hasMoreChunks = false;
    RawHeaders rawResponseHeaders = httpEngine.responseHeaders.getHeaders();
    RawHeaders.readHeaders(transport.socketIn, rawResponseHeaders);
    httpEngine.receiveHeaders(rawResponseHeaders);
    endOfInput();
  }
}
 
Example 2
Source File: HttpTransport.java    From IoTgo_Android_App with MIT License 6 votes vote down vote up
private void readChunkSize() throws IOException {
  // read the suffix of the previous chunk
  if (bytesRemainingInChunk != NO_CHUNK_YET) {
    Util.readAsciiLine(in);
  }
  String chunkSizeString = Util.readAsciiLine(in);
  int index = chunkSizeString.indexOf(";");
  if (index != -1) {
    chunkSizeString = chunkSizeString.substring(0, index);
  }
  try {
    bytesRemainingInChunk = Integer.parseInt(chunkSizeString.trim(), 16);
  } catch (NumberFormatException e) {
    throw new ProtocolException("Expected a hex chunk size but was " + chunkSizeString);
  }
  if (bytesRemainingInChunk == 0) {
    hasMoreChunks = false;
    RawHeaders rawResponseHeaders = httpEngine.responseHeaders.getHeaders();
    RawHeaders.readHeaders(transport.socketIn, rawResponseHeaders);
    httpEngine.receiveHeaders(rawResponseHeaders);
    endOfInput();
  }
}
 
Example 3
Source File: HttpTransport.java    From android-discourse with Apache License 2.0 6 votes vote down vote up
private void readChunkSize() throws IOException {
    // read the suffix of the previous chunk
    if (bytesRemainingInChunk != NO_CHUNK_YET) {
        Util.readAsciiLine(in);
    }
    String chunkSizeString = Util.readAsciiLine(in);
    int index = chunkSizeString.indexOf(";");
    if (index != -1) {
        chunkSizeString = chunkSizeString.substring(0, index);
    }
    try {
        bytesRemainingInChunk = Integer.parseInt(chunkSizeString.trim(), 16);
    } catch (NumberFormatException e) {
        throw new ProtocolException("Expected a hex chunk size but was " + chunkSizeString);
    }
    if (bytesRemainingInChunk == 0) {
        hasMoreChunks = false;
        RawHeaders rawResponseHeaders = httpEngine.responseHeaders.getHeaders();
        RawHeaders.readHeaders(transport.socketIn, rawResponseHeaders);
        httpEngine.receiveHeaders(rawResponseHeaders);
        endOfInput();
    }
}
 
Example 4
Source File: HttpTransport.java    From bluemix-parking-meter with MIT License 6 votes vote down vote up
private void readChunkSize() throws IOException {
  // read the suffix of the previous chunk
  if (bytesRemainingInChunk != NO_CHUNK_YET) {
    Util.readAsciiLine(in);
  }
  String chunkSizeString = Util.readAsciiLine(in);
  int index = chunkSizeString.indexOf(";");
  if (index != -1) {
    chunkSizeString = chunkSizeString.substring(0, index);
  }
  try {
    bytesRemainingInChunk = Integer.parseInt(chunkSizeString.trim(), 16);
  } catch (NumberFormatException e) {
    throw new ProtocolException("Expected a hex chunk size but was " + chunkSizeString);
  }
  if (bytesRemainingInChunk == 0) {
    hasMoreChunks = false;
    RawHeaders rawResponseHeaders = httpEngine.responseHeaders.getHeaders();
    RawHeaders.readHeaders(transport.socketIn, rawResponseHeaders);
    httpEngine.receiveHeaders(rawResponseHeaders);
    endOfInput();
  }
}
 
Example 5
Source File: HttpTransport.java    From reader with MIT License 6 votes vote down vote up
private void readChunkSize() throws IOException {
  // read the suffix of the previous chunk
  if (bytesRemainingInChunk != NO_CHUNK_YET) {
    Util.readAsciiLine(in);
  }
  String chunkSizeString = Util.readAsciiLine(in);
  int index = chunkSizeString.indexOf(";");
  if (index != -1) {
    chunkSizeString = chunkSizeString.substring(0, index);
  }
  try {
    bytesRemainingInChunk = Integer.parseInt(chunkSizeString.trim(), 16);
  } catch (NumberFormatException e) {
    throw new ProtocolException("Expected a hex chunk size but was " + chunkSizeString);
  }
  if (bytesRemainingInChunk == 0) {
    hasMoreChunks = false;
    RawHeaders rawResponseHeaders = httpEngine.responseHeaders.getHeaders();
    RawHeaders.readHeaders(transport.socketIn, rawResponseHeaders);
    httpEngine.receiveHeaders(rawResponseHeaders);
    endOfInput();
  }
}
 
Example 6
Source File: HttpTransport.java    From reader with MIT License 6 votes vote down vote up
private void readChunkSize() throws IOException {
  // read the suffix of the previous chunk
  if (bytesRemainingInChunk != NO_CHUNK_YET) {
    Util.readAsciiLine(in);
  }
  String chunkSizeString = Util.readAsciiLine(in);
  int index = chunkSizeString.indexOf(";");
  if (index != -1) {
    chunkSizeString = chunkSizeString.substring(0, index);
  }
  try {
    bytesRemainingInChunk = Integer.parseInt(chunkSizeString.trim(), 16);
  } catch (NumberFormatException e) {
    throw new ProtocolException("Expected a hex chunk size but was " + chunkSizeString);
  }
  if (bytesRemainingInChunk == 0) {
    hasMoreChunks = false;
    RawHeaders rawResponseHeaders = httpEngine.responseHeaders.getHeaders();
    RawHeaders.readHeaders(transport.socketIn, rawResponseHeaders);
    httpEngine.receiveHeaders(rawResponseHeaders);
    endOfInput();
  }
}
 
Example 7
Source File: HttpTransport.java    From cordova-amazon-fireos with Apache License 2.0 6 votes vote down vote up
private void readChunkSize() throws IOException {
  // read the suffix of the previous chunk
  if (bytesRemainingInChunk != NO_CHUNK_YET) {
    Util.readAsciiLine(in);
  }
  String chunkSizeString = Util.readAsciiLine(in);
  int index = chunkSizeString.indexOf(";");
  if (index != -1) {
    chunkSizeString = chunkSizeString.substring(0, index);
  }
  try {
    bytesRemainingInChunk = Integer.parseInt(chunkSizeString.trim(), 16);
  } catch (NumberFormatException e) {
    throw new ProtocolException("Expected a hex chunk size but was " + chunkSizeString);
  }
  if (bytesRemainingInChunk == 0) {
    hasMoreChunks = false;
    RawHeaders rawResponseHeaders = httpEngine.responseHeaders.getHeaders();
    RawHeaders.readHeaders(transport.socketIn, rawResponseHeaders);
    httpEngine.receiveHeaders(rawResponseHeaders);
    endOfInput();
  }
}
 
Example 8
Source File: HttpTransport.java    From phonegapbootcampsite with MIT License 6 votes vote down vote up
private void readChunkSize() throws IOException {
  // read the suffix of the previous chunk
  if (bytesRemainingInChunk != NO_CHUNK_YET) {
    Util.readAsciiLine(in);
  }
  String chunkSizeString = Util.readAsciiLine(in);
  int index = chunkSizeString.indexOf(";");
  if (index != -1) {
    chunkSizeString = chunkSizeString.substring(0, index);
  }
  try {
    bytesRemainingInChunk = Integer.parseInt(chunkSizeString.trim(), 16);
  } catch (NumberFormatException e) {
    throw new ProtocolException("Expected a hex chunk size but was " + chunkSizeString);
  }
  if (bytesRemainingInChunk == 0) {
    hasMoreChunks = false;
    RawHeaders rawResponseHeaders = httpEngine.responseHeaders.getHeaders();
    RawHeaders.readHeaders(transport.socketIn, rawResponseHeaders);
    httpEngine.receiveHeaders(rawResponseHeaders);
    endOfInput();
  }
}
 
Example 9
Source File: HttpTransport.java    From CordovaYoutubeVideoPlayer with MIT License 6 votes vote down vote up
private void readChunkSize() throws IOException {
  // read the suffix of the previous chunk
  if (bytesRemainingInChunk != NO_CHUNK_YET) {
    Util.readAsciiLine(in);
  }
  String chunkSizeString = Util.readAsciiLine(in);
  int index = chunkSizeString.indexOf(";");
  if (index != -1) {
    chunkSizeString = chunkSizeString.substring(0, index);
  }
  try {
    bytesRemainingInChunk = Integer.parseInt(chunkSizeString.trim(), 16);
  } catch (NumberFormatException e) {
    throw new ProtocolException("Expected a hex chunk size but was " + chunkSizeString);
  }
  if (bytesRemainingInChunk == 0) {
    hasMoreChunks = false;
    RawHeaders rawResponseHeaders = httpEngine.responseHeaders.getHeaders();
    RawHeaders.readHeaders(transport.socketIn, rawResponseHeaders);
    httpEngine.receiveHeaders(rawResponseHeaders);
    endOfInput();
  }
}
 
Example 10
Source File: HttpTransport.java    From cordova-android-chromeview with Apache License 2.0 6 votes vote down vote up
private void readChunkSize() throws IOException {
  // read the suffix of the previous chunk
  if (bytesRemainingInChunk != NO_CHUNK_YET) {
    Util.readAsciiLine(in);
  }
  String chunkSizeString = Util.readAsciiLine(in);
  int index = chunkSizeString.indexOf(";");
  if (index != -1) {
    chunkSizeString = chunkSizeString.substring(0, index);
  }
  try {
    bytesRemainingInChunk = Integer.parseInt(chunkSizeString.trim(), 16);
  } catch (NumberFormatException e) {
    throw new ProtocolException("Expected a hex chunk size but was " + chunkSizeString);
  }
  if (bytesRemainingInChunk == 0) {
    hasMoreChunks = false;
    RawHeaders rawResponseHeaders = httpEngine.responseHeaders.getHeaders();
    RawHeaders.readHeaders(transport.socketIn, rawResponseHeaders);
    httpEngine.receiveHeaders(rawResponseHeaders);
    endOfInput(false);
  }
}
 
Example 11
Source File: HttpTransport.java    From wildfly-samples with MIT License 6 votes vote down vote up
private void readChunkSize() throws IOException {
  // read the suffix of the previous chunk
  if (bytesRemainingInChunk != NO_CHUNK_YET) {
    Util.readAsciiLine(in);
  }
  String chunkSizeString = Util.readAsciiLine(in);
  int index = chunkSizeString.indexOf(";");
  if (index != -1) {
    chunkSizeString = chunkSizeString.substring(0, index);
  }
  try {
    bytesRemainingInChunk = Integer.parseInt(chunkSizeString.trim(), 16);
  } catch (NumberFormatException e) {
    throw new ProtocolException("Expected a hex chunk size but was " + chunkSizeString);
  }
  if (bytesRemainingInChunk == 0) {
    hasMoreChunks = false;
    RawHeaders rawResponseHeaders = httpEngine.responseHeaders.getHeaders();
    RawHeaders.readHeaders(transport.socketIn, rawResponseHeaders);
    httpEngine.receiveHeaders(rawResponseHeaders);
    endOfInput();
  }
}
 
Example 12
Source File: HttpTransport.java    From phonegap-plugin-loading-spinner with Apache License 2.0 6 votes vote down vote up
private void readChunkSize() throws IOException {
  // read the suffix of the previous chunk
  if (bytesRemainingInChunk != NO_CHUNK_YET) {
    Util.readAsciiLine(in);
  }
  String chunkSizeString = Util.readAsciiLine(in);
  int index = chunkSizeString.indexOf(";");
  if (index != -1) {
    chunkSizeString = chunkSizeString.substring(0, index);
  }
  try {
    bytesRemainingInChunk = Integer.parseInt(chunkSizeString.trim(), 16);
  } catch (NumberFormatException e) {
    throw new ProtocolException("Expected a hex chunk size but was " + chunkSizeString);
  }
  if (bytesRemainingInChunk == 0) {
    hasMoreChunks = false;
    RawHeaders rawResponseHeaders = httpEngine.responseHeaders.getHeaders();
    RawHeaders.readHeaders(transport.socketIn, rawResponseHeaders);
    httpEngine.receiveHeaders(rawResponseHeaders);
    endOfInput(false);
  }
}
 
Example 13
Source File: HttpTransport.java    From crosswalk-cordova-android with Apache License 2.0 6 votes vote down vote up
private void readChunkSize() throws IOException {
  // read the suffix of the previous chunk
  if (bytesRemainingInChunk != NO_CHUNK_YET) {
    Util.readAsciiLine(in);
  }
  String chunkSizeString = Util.readAsciiLine(in);
  int index = chunkSizeString.indexOf(";");
  if (index != -1) {
    chunkSizeString = chunkSizeString.substring(0, index);
  }
  try {
    bytesRemainingInChunk = Integer.parseInt(chunkSizeString.trim(), 16);
  } catch (NumberFormatException e) {
    throw new ProtocolException("Expected a hex chunk size but was " + chunkSizeString);
  }
  if (bytesRemainingInChunk == 0) {
    hasMoreChunks = false;
    RawHeaders rawResponseHeaders = httpEngine.responseHeaders.getHeaders();
    RawHeaders.readHeaders(transport.socketIn, rawResponseHeaders);
    httpEngine.receiveHeaders(rawResponseHeaders);
    endOfInput();
  }
}