Transfer file using http to client. Pipes a file through Drupal to the client.

Paramètres

$source File to transfer.:

$headers An array of http headers to send along with file.:

1 call to advagg_missing_file_transfer()
advagg_missing_send_file dans includes/missing.inc
Send the file or send a 307 redirect.

Fichier

includes/missing.inc, line 285

Code

function advagg_missing_file_transfer($source, $headers) {
    $source = advagg_missing_file_create_path($source);
    $fd = fopen($source, 'rb');
    // Return if we can't open the file. Will try a 307 in browser to send file.
    if (!$fd) {
        return;
    }
    // Clear the buffer.
    if (ob_get_level()) {
        ob_end_clean();
    }
    // Add in headers.
    foreach ($headers as $header) {
        // To prevent HTTP header injection, we delete new lines that are
        // not followed by a space or a tab.
        // See http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2
        $header = preg_replace('/\\r?\\n(?!\\t| )/', '', $header);
        drupal_add_http_header($header);
    }
    // Transfer file in 8096 byte chunks.
    while (!feof($fd)) {
        print fread($fd, 8096);
    }
    fclose($fd);
    exit;
}