def peek(self, size): cd, out = pn_transport_peek(self._impl, size) if cd == PN_EOS: return None else: self._check(cd) return out
def peek(self, size: int) -> Optional[bytes]: """ Returns ``size`` bytes from the head of the transport. It is an error to call this with a value of ``size`` that is greater than the value reported by :meth:`pending`. :param size: Number of bytes to return. :return: ``size`` bytes from the head of the transport, or ``None`` if none are available. :raise: :exc:`TransportException` if there is any Proton error. """ cd, out = pn_transport_peek(self._impl, size) if cd == PN_EOS: return None else: self._check(cd) return out