- if (!empty($this->sniffContent) && $this->responseOffset < $sniffOffset) {
- $sniffOutput = substr($this->sniffContent, $this->responseOffset, min($sniffOffset, $this->responseLength));
+ if ($sniffLength > 0 && $this->responseOffset < $sniffLength) {
+ $sniffEnd = min($sniffLength, $bytesToWrite + $this->responseOffset);
+ $sniffOutLength = $sniffEnd - $this->responseOffset;
+ $sniffOutput = substr($this->sniffContent, $this->responseOffset, $sniffOutLength);