server/lib/public/appframework/http/ioutput.php
Bernhard Posselt 95239ad21e AppFramework StreamResponse
First stab at the StreamResponse, see #12988

The idea is to use an interface ICallbackResponse (I'm not 100% happy with the name yet, suggestions?) that allow the response to output things in its own way, for instance stream the file using readfile

Unittests are atm lacking, plan is to

check if a mock of ICallbackResponse will be used by calling its callback (also unhappy with this name) method
Usage is:

$response = new StreamResponse('path/to/file');

rename io to output, add additional methods and handle error and not modified cases when using StreamResponse

fix indention and uppercasing, also handle forbidden cases

fix indention

fix indention

no forbidden, figuring out if a file is really readable is too complicated to get to work across OSes and streams

remove useless import

remove useless import

fix intendation
2015-02-27 15:42:33 +01:00

57 lines
1.1 KiB
PHP

<?php
/**
* @author Bernhard Posselt
* @copyright 2015 Bernhard Posselt <dev@bernhard-posselt.com>
*
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
namespace OCP\AppFramework\Http;
/**
* Very thin wrapper class to make output testable
*/
interface IOutput {
/**
* @param string $out
*/
public function setOutput($out);
/**
* @param string $path
*
* @return bool false if an error occured
*/
public function setReadfile($path);
/**
* @param string $header
*/
public function setHeader($header);
/**
* @return int returns the current http response code
*/
public function getHttpResponseCode();
/**
* @param int $code sets the http status code
*/
public function setHttpResponseCode($code);
/**
* @param string $name
* @param string $value
* @param int $expire
* @param string $path
* @param string $domain
* @param bool $secure
* @param bool $httponly
*/
public function setCookie($name, $value, $expire, $path, $domain, $secure, $httponly);
}