Access the proper output buffer for the current write attempt.

@return WsByteBuffer
516119
protected WsByteBuffer getBuffer() {
        WsByteBuffer buffer = this.output[this.outputIndex];
        if (null == buffer) {
            buffer = HttpDispatcher.getBufferManager().allocate(this.bbSize);
            buffer.clear();
            this.output[this.outputIndex] = buffer;
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "getBuffer, buffer -->" + buffer + " ,outputIndex -->" + this.outputIndex);
            }
        } else if (!buffer.hasRemaining()) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "getBuffer, buffer  -->" + buffer + " ,outputIndex -->" + this.outputIndex + " output length -->" + this.output.length);
            }
            buffer.flip();
            this.outputIndex++;
            // next array spot may or may not exist from previous iterations
            if (null == this.output[this.outputIndex]) {
                this.output[this.outputIndex] = HttpDispatcher.getBufferManager().allocate(this.bbSize);
            }
            buffer = this.output[this.outputIndex];
            buffer.clear();
        }
        return buffer;
    }
309423
protected static function is_current_output_buffer() : bool {
        if (empty(self::$taskloginfo)) {
            return false;
        }

        if ($ob = ob_get_status()) {
            return 'core\\task\\logmanager::add_line' == $ob['name'];
        }

        return false;
    }
1322929
public function stream_flush()
    {
        if (!$this->getResource()) {
            return false;
        }

        $buffer = $this->getDataBuffer();
        $bufferWritten = $buffer;
        $retVal = true;
        if (!empty($buffer)) {

            $object = $this->getResource()->getObject();
            $mimetype = $this->getService()->guessFileType($this->getResource()->getResourceName());
            $object->content_type = $mimetype;
            $object->setData($buffer);
            $object->Create();
        }

       if (strlen($bufferWritten) ==  strlen($buffer)) {
            $this->setDataBuffer(null);
        } else {
            $this->setDataBuffer($buffer);
        }
        $this->setDataBuffer(null);

        return $retVal;
    }
1332473
public static function startOutputBuffer()
    {
        if (ob_get_level() > 1) {
            return;
        }
        
        $outputCallback = null;
        if (GZIP_SUPPORTED && !DISABLE_GZIP) {
            $outputCallback = 'ob_gzhandler';
        }
        
        if (in_array($outputCallback, ob_list_handlers())) {
            return; // don't start same handler twice
        }
        
        ob_start($outputCallback);
    }
916415
function flush()
    {
        /*
         * If output buffering is enabled, dump the contents of the buffer to
         * the output stream.
         */
        if ($this->_buffering && (strlen($this->_buffer) > 0)) {
            fwrite($this->_stream, $this->_buffer);
            $this->_buffer = '';
        }

        if (is_resource($this->_stream)) {
            return fflush($this->_stream);
        }

        return false;
    }
994752
@Override
    public WsByteBuffer[] marshallLine() {
        WsByteBuffer[] firstLine = new WsByteBuffer[1];
        firstLine[0] = allocateBuffer(getOutgoingBufferSize());

        firstLine = putBytes(getVersionValue().getByteArray(), firstLine);
        firstLine = putByte(SPACE, firstLine);
        if (null == this.myReasonBytes) {
            // use the default value
            firstLine = putBytes(this.myStatusCode.getStatusWithPhrase(), firstLine);
        } else {
            // put the status code then the phrase
            firstLine = putBytes(this.myStatusCode.getByteArray(), firstLine);
            firstLine = putByte(SPACE, firstLine);
            firstLine = putBytes(getReasonPhraseBytes(), firstLine);
        }
        firstLine = putBytes(BNFHeaders.EOL, firstLine);
        // don't flip the last buffer as headers get tacked on the end
        if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
            Tr.event(tc, "Marshalling first line: " + getVersion() + " " + getStatusCodeAsInt() + " " + getReasonPhrase());
        }
        return firstLine;
    }
362625
static function captureBuffers(?int $targetLevel = null, bool $catchExceptions = false): string
    {
        $output = '';
        $stopLevel = $targetLevel ?? 0;

        foreach (self::iterateBufferLevels(PHP_OUTPUT_HANDLER_CLEANABLE) as $level) {
            if ($level <= $stopLevel) {
                break;
            }

            try {
                $output = ob_get_clean() . $output;
            } catch (\Throwable $e) {
                if (!$catchExceptions) {
                    throw $e;
                }
            }
        }

        return $output;
    }
147418
public ByteBuffer preProcessOneWriteBuffer() {
        // We can process the single buffer case more efficiently than if we
        // include it as a part of the multi-buffer logic
        WsByteBufferImpl wsBuffImpl = null;
        try {
            wsBuffImpl = (WsByteBufferImpl) getBuffer();
        } catch (ClassCastException cce) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Writing with a non-WsByteBufferImpl");
            }
            return getBuffer().getWrappedByteBuffer();
        }

        if (!wsBuffImpl.isDirect() && wsBuffImpl.hasArray()) {
            wsBuffImpl.copyToDirectBuffer();
            return wsBuffImpl.oWsBBDirect;
        }
        return wsBuffImpl.getWrappedByteBufferNonSafe();
    }
265181
public byte[] getOutput() {
		if (stringWriter != null) {
			byte[] output = null;

			String string = stringWriter.toString();
			if (string != null) {
				try {
					output = string.getBytes(characterEncoding);
				} catch (UnsupportedEncodingException uue) {
					output = null;
				}
			}

			return output;
		} else if (outputStream != null) {
			return outputStream.getOutput();
		}

		return null;
	}
1330375
public OutputStream getOutputStream()
    throws IOException
  {
    if (_os == null)
      _os = new FileOutputStream(_file.getFD());

    return _os;
  }
127238
public function stream()
	{
		$fp = fopen("php://memory", 'r+');
		fwrite($fp, $this->_string);
		rewind($fp);
		return $fp;
	}
1001065
@Override
    public OutputStream getOutputStream() throws IOException {
	if (!_file.isWriteable()) {
	    throw new IOException("Cannot write");
	}
	return IOUtil.toBufferedOutputStream(_file.getOutputStream());
    }
420672
private function outputBuffer($filename = null, $output = false)
    {
        if (!$this->resource) {
            return $this;
        }

        if ($output) {
            $filename = null;
        } elseif (empty($filename) && $this->isLocal()) {
            $filename = $this->filename;
        } elseif (empty($filename) && $this->isExternal()) {
            $filename = $this->name;
        }

        if ($output) {
            header('Content-type: ' . $this->mimetype);
            ob_start();
        }

        $this->outputBufferByImage($filename, $this->quality);

        if ($output) {
            ob_end_flush();
        }

        if (!$this->preserve) {
            $this->destroy();
        }

        return $this;
    }
446132
protected function getBinaryBuffer() {
		// catch the GD2 output
		ob_start();

		// convert a (probably) color/greyscale image to the monochrome counterpart.
		imagewbmp($this->image);

		// catch contents of the WBMP file.
		$wbmp = ob_get_clean();

		// ignore 2 bytes of WBMP file header
		$i = 2;

		// ignore 2 VLQ's (variable-length quantities) describing WBMP resolution.
		for($j = 0; $j < 2; ++$j) {
			do {
				$test = ord($wbmp[$i]) & 0x80;
				++$i;
			} while($test);
		}

		// return binary buffer as a string of chars (bytes)
		return substr($wbmp, $i);
	}
705650
protected String printBuffer() {
        String javaStr = new String(input.getBuffer());
        javaStr = javaStr.replaceAll("\\r", "\\\\r");
        javaStr = javaStr.replaceAll("\\n", "\\\\n");
        return javaStr;
    }
38659
private java.nio.ByteBuffer getWritingRow() {
        final int row = this.writerIndex / this.localCapacity;
        if (row >= this.storage.size()) {
            final java.nio.ByteBuffer buf = java.nio.ByteBuffer.allocate(this.localCapacity);
            this.storage.add(buf);
            return buf;
        }

        return this.storage.get(row);
    }
908943
@Override
    public SmbPipeOutputStream getOutput () throws CIFSException {
        if ( !this.open ) {
            throw new SmbException("Already closed");
        }

        if ( this.output != null ) {
            return this.output;
        }

        try ( SmbTreeHandleImpl th = ensureTreeConnected() ) {
            this.output = new SmbPipeOutputStream(this, th);
        }
        return this.output;
    }