Returns a tuple of (data, end_of_http_chunk). When chunked transfer
        encoding is used, end_of_http_chunk is a boolean indicating if the end
        of the data corresponds to the end of a HTTP chunk , otherwise it is
        always False.
436468
async def readchunk(self) -> Tuple[bytes, bool]:
        
        while True:
            if self._exception is not None:
                raise self._exception

            while self._http_chunk_splits:
                pos = self._http_chunk_splits.pop(0)
                if pos == self._cursor:
                    return (b"", True)
                if pos > self._cursor:
                    return (self._read_nowait(pos-self._cursor), True)
                internal_logger.warning('Skipping HTTP chunk end due to data '
                                        'consumption beyond chunk boundary')

            if self._buffer:
                return (self._read_nowait_chunk(-1), False)
                # return (self._read_nowait(-1), False)

            if self._eof:
                # Special case for signifying EOF.
                # (b'', True) is not a final return value actually.
                return (b'', False)

            await self._wait('readchunk')
827587
@Synchronized
    public boolean isEndOfData() {
        return futureSegments.isEmpty() && unassignedSegments.isEmpty() &&
                assignedSegments.values().stream().allMatch(Map::isEmpty);
    }
136803
public boolean isLast() {
        Object isLast = getHeader(WebSocketMessageHeaders.WEB_SOCKET_IS_LAST);

        if (isLast != null) {
            if (isLast instanceof String) {
                return Boolean.valueOf(isLast.toString());
            } else {
                return (Boolean) isLast;
            }
        }

        return true;
    }
58280
def decode_data(self, data):
        
        assert self.get_empty() is False
        assert self._data_encoded is True
        if self._block_allowed:
            data = self._decode_transfer_block_data(data)
        else:
            data = self._decode_transfer_data(data)
        return data
931482
def endswith(self, suffix, start=None, end=None):
        
        suffix = Bits(suffix)
        start, end = self._validate_slice(start, end)
        if start + suffix.len > end:
            return False
        start = end - suffix.len
        return self._slice(start, end) == suffix
527572
private boolean useChunkEncoding(SignableRequest<?> request) {
        // If chunked encoding is explicitly disabled through client options return right here.
        // Chunked encoding only makes sense to do when the payload is signed
        if (!isPayloadSigningEnabled(request) || isChunkedEncodingDisabled(request)) {
            return false;
        }
        if (request.getOriginalRequestObject() instanceof PutObjectRequest
                || request.getOriginalRequestObject() instanceof UploadPartRequest) {
            return true;
        }
        return false;
    }
341329
function chunkLength (chunk, encoding) {
  if (!chunk) {
    return 0
  }

  return !Buffer.isBuffer(chunk)
    ? Buffer.byteLength(chunk, encoding)
    : chunk.length
}
973564
def _to_bytes(self, data):
        
        # TODO: On Python 3, move this `if` line to the `except` branch
        # as the common case will indeed no longer be bytes.
        if not isinstance(data, bytes):
            try:
                return data.encode('utf-8')
            except Exception:
                return None

        return data
1011587
def eof?
      fail IOError, "closed stream" if closed?

      return false if cache && !cache.eof?
      @buffer.nil? && chunks_depleted?
    end
272060
public function parseChunk($data)
    {
        if (!$data) {
            return;
        }
        // Detect end of transfer
        if ($end = strpos($data, "0\r\n\r\n")) {
            $data = substr($data, 0, $end);
        }
        $this->buffer.= $data;
        $this->request->onData($data);

        if ($end) {
            $this->buffer = $this->parseChunkedBuffer($this->buffer);
            $this->request->setBody($this->buffer);
            $this->notifyCompleted();
            $this->buffer = '';
        }
    }
672656
def _EndRecData(fpin):
    """"""

    # Determine file size
    fpin.seek(0, 2)
    filesize = fpin.tell()

    # Check to see if this is ZIP file with no archive comment (the
    # "end of central directory" structure should be the last item in the
    # file if this is the case).
    try:
        fpin.seek(-sizeEndCentDir, 2)
    except IOError:
        return None
    data = fpin.read()
    if data[0:4] == stringEndArchive and data[-2:] == "\000\000":
        # the signature is correct and there's no comment, unpack structure
        endrec = struct.unpack(structEndArchive, data)
        endrec=list(endrec)

        # Append a blank comment and record start offset
        endrec.append("")
        endrec.append(filesize - sizeEndCentDir)

        # Try to read the "Zip64 end of central directory" structure
        return _EndRecData64(fpin, -sizeEndCentDir, endrec)

    # Either this is not a ZIP file, or it is a ZIP file with an archive
    # comment.  Search the end of the file for the "end of central directory"
    # record signature. The comment is the last item in the ZIP file and may be
    # up to 64K long.  It is assumed that the "end of central directory" magic
    # number does not appear in the comment.
    maxCommentStart = max(filesize - (1 << 16) - sizeEndCentDir, 0)
    fpin.seek(maxCommentStart, 0)
    data = fpin.read()
    start = data.rfind(stringEndArchive)
    if start >= 0:
        # found the magic number; attempt to unpack and interpret
        recData = data[start:start+sizeEndCentDir]
        endrec = list(struct.unpack(structEndArchive, recData))
        comment = data[start+sizeEndCentDir:]
        # check that comment length is correct
        if endrec[_ECD_COMMENT_SIZE] == len(comment):
            # Append the archive comment and start offset
            endrec.append(comment)
            endrec.append(maxCommentStart + start)

            # Try to read the "Zip64 end of central directory" structure
            return _EndRecData64(fpin, maxCommentStart + start - filesize,
                                 endrec)

    # Unable to find a valid end of central directory structure
    return
1163630
def _as_chunk(self):
        

        extra_bits = int_from_bytes(self.contents[0:1])
        bit_string = '{0:b}'.format(int_from_bytes(self.contents[1:]))

        # Ensure we have leading zeros since these chunks may be concatenated together
        mod_bit_len = len(bit_string) % 8
        if mod_bit_len != 0:
            bit_string = ('0' * (8 - mod_bit_len)) + bit_string

        if extra_bits > 0:
            return bit_string[0:0 - extra_bits]

        return bit_string
1153937
def endianSwapU16(bytes):
    """"""
    for b in range(0, len(bytes), 2):
        bytes[b], bytes[b + 1] = bytes[b + 1], bytes[b]
    return bytes
623044
def has_end(self, stream):
        
        for token in self.end_tokens:
            if not self.has_next(token, stream):
                continue

            offset = len(token)

            if self.has_eof(stream, offset):
                return True

            if self.has_whitespace(stream, offset):
                return True

            if self.has_comment(stream, offset):
                return True

            if self.has_next(self.statement_delimiter, stream, offset):
                return True

        return self.has_eof(stream)
86781
def _get_content_range(start: Optional[int], end: Optional[int], total: int) -> str:
    
    start = start or 0
    end = (end or total) - 1
    return "bytes %s-%s/%s" % (start, end, total)
182284
private static int findEndOfHeader(byte[] pBytes, int pEnd) {
        byte[] header = HTTP_HEADER_END.getBytes();

        // Normal condition, check all bytes
        for (int i = 0; i < pEnd - 4; i++) {  // Need 4 bytes to match
            if ((pBytes[i] == header[0]) && (pBytes[i + 1] == header[1]) && (pBytes[i + 2] == header[2]) && (pBytes[i + 3] == header[3])) {

                //System.err.println("FOUND END OF HEADER!");
                return i + 4;
            }
        }

        // Check last 3 bytes, to check if we have a partial match
        if ((pEnd - 1 >= 0) && (pBytes[pEnd - 1] == header[0])) {

            //System.err.println("FOUND LAST BYTE");
            return -2;  // LAST BYTE
        }
        else if ((pEnd - 2 >= 0) && (pBytes[pEnd - 2] == header[0]) && (pBytes[pEnd - 1] == header[1])) {

            //System.err.println("FOUND LAST TWO BYTES");
            return -3;  // LAST TWO BYTES
        }
        else if ((pEnd - 3 >= 0) && (pBytes[pEnd - 3] == header[0]) && (pBytes[pEnd - 2] == header[1]) && (pBytes[pEnd - 1] == header[2])) {

            //System.err.println("FOUND LAST THREE BYTES");
            return -4;  // LAST THREE BYTES
        }
        return -1;  // NO BYTES MATCH
    }
1140249
def parseChunk(self, chunk, size, terminate):
        
        ret = libxml2mod.xmlParseChunk(self._o, chunk, size, terminate)
        return ret