Base64EncodeStreamFilter extends php_user_filter
Unfortunately neither the built-in base64 encoder in PHP, nor the HHVM implementation for their ConvertFilter seem to handle large streams correctly. There appears to be no provision for data coming in when they're not split on 3 byte-chunks (each 3-byte chunk trnaslates to 4-bytes of base64 encoded data).
Tags
Table of Contents
- STREAM_FILTER_NAME = 'mmp-convert.base64-encode'
- Name used when registering with stream_filter_register.
- $leftovers : StreamLeftover
- $numBytesWritten : int
- filter() : int
- Filter implementation converts encoding before returning PSFS_PASS_ON.
- onCreate() : mixed
- Sets up the leftovers object
- convertAndAppend() : mixed
- Base64-encodes the passed $data string and appends it to $out.
- readAndConvert() : mixed
- Reads from the input bucket stream, converts, and writes the uuencoded stream to $out.
Constants
STREAM_FILTER_NAME
Name used when registering with stream_filter_register.
public
mixed
STREAM_FILTER_NAME
= 'mmp-convert.base64-encode'
Properties
$leftovers
private
StreamLeftover
$leftovers
$numBytesWritten
private
int
$numBytesWritten
= 0
Methods
filter()
Filter implementation converts encoding before returning PSFS_PASS_ON.
public
filter(resource $in, resource $out, int &$consumed, bool $closing) : int
Parameters
- $in : resource
- $out : resource
- $consumed : int
- $closing : bool
Return values
int —onCreate()
Sets up the leftovers object
public
onCreate() : mixed
Return values
mixed —convertAndAppend()
Base64-encodes the passed $data string and appends it to $out.
private
convertAndAppend(string $data, resource $out) : mixed
Parameters
- $data : string
-
data to convert
- $out : resource
-
output bucket stream
Return values
mixed —readAndConvert()
Reads from the input bucket stream, converts, and writes the uuencoded stream to $out.
private
readAndConvert(resource $in, resource $out, int &$consumed) : mixed
Parameters
- $in : resource
-
input bucket stream
- $out : resource
-
output bucket stream
- $consumed : int
-
incremented by number of bytes read from $in