Search by

catatsumuri / http-download

catatsumuri

PEAR HTTP_Download, HTTP_Header and HTTP packaged for Composer, unchanged except for the few lines listed in NOTICE.md

Package info

github.com/catatsumuri/http-download

pkg:composer/catatsumuri/http-download

Statistics

Installs: 3

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-10-28 11:32 UTC

This package is auto-updated.

Last update: 2026-10-28 11:37:15 UTC


README

PEAR's HTTP_Download, HTTP_Header and HTTP, packaged for Composer.

HTTP_Download sends files or in-memory data to the browser as a download or inline content and answers conditional (ETag, 304) and byte-range (206, 416, multipart) requests by itself. These packages are not available on Packagist under pear/…, and PEAR's own installer is not an option for Composer-based applications, so the original source is published here as it was released, with the provenance recorded in NOTICE.md.

PEAR の HTTP_Download / HTTP_Header / HTTP を、Composer で使えるようにそのまま パッケージにしたものです。元のソースとの差分は NOTICE.md に全部書いてあります。

Install

composer require catatsumuri/http-download

Requires PHP 5.6 or later and pear/pear-core-minimal. The include-path entry in composer.json keeps the original require_once 'HTTP/Download.php'; working.

Use

require_once 'HTTP/Download.php';

$download = new HTTP_Download();
$download->setData($bytes);                       // or setFile($path)
$download->setContentDisposition(HTTP_DOWNLOAD_ATTACHMENT, 'report.pdf');
$download->setContentType('application/pdf');
$download->send();

The API is documented in the original HTTP_Download manual.

Status

This is a faithful copy of old code (HTTP_Download 1.1.4 is from 2010). The smoke test passes on PHP 7.4 (the PHP 4 style constructors raise deprecation notices there). The code comes from the PHP 5 era, but this package has not been run on PHP 5.6. It is not PHP 8 compatible. See "Known issues" in NOTICE.md. Fixes are made here, in this package.

Test

php tests/smoke.php /path/to/a/project/vendor/autoload.php

The smoke test starts PHP's built-in web server and checks real HTTP exchanges (attachment and inline with a Japanese file name, ETag/304, Range/206, 416, a file served with setFile()). The autoload file is only needed to find pear/pear-core-minimal.

License

3-clause BSD, with the copyright holders of the original packages. See LICENSE, licenses/ and NOTICE.md.