HTTPStreamResponse
class HTTPStreamResponse extends HTTPResponse (View source)
A response which contains a streamable data source.
Traits
A class that can be instantiated or replaced via DI
Properties
| protected static | array | $status_codes | from HTTPResponse | |
| protected static | array | $redirect_codes | from HTTPResponse | |
| protected | string | $protocolVersion | from HTTPResponse | |
| protected | int | $statusCode | from HTTPResponse | |
| protected | string | $statusDescription | from HTTPResponse | |
| protected | array | $headers | HTTP Headers like "content-type: text/xml" | from HTTPResponse | 
| protected | string | $body | from HTTPResponse | |
| protected | resource | $stream | Stream source for this response | |
| protected | bool | $consumed | Set to true if this stream has been consumed. | 
Methods
An implementation of the factory method, allows you to create an instance of a class
Creates a class instance by the "singleton" design pattern.
HTTPStreamResponse constructor.
The HTTP version used to respond to this request (typically 1.0 or 1.1)
The text to be given alongside the status code ("reason phrase").
Add a HTTP header to the response, replacing any header of the same name.
Remove an existing HTTP header by its name, e.g. "Content-Type".
Returns true if this response is "finished", that is, no more script execution should be done.
Details
        
                static            Injectable
    create(mixed ...$args)
        
    
    An implementation of the factory method, allows you to create an instance of a class
This method will defer class substitution to the Injector API, which can be customised via the Config API to declare substitution classes.
This can be called in one of two ways - either calling via the class directly, or calling on Object and passing the class name as the first parameter. The following are equivalent: $list = DataList::create(SiteTree::class); $list = SiteTree::get();
        
                static            Injectable
    singleton(string $class = null)
        
    
    Creates a class instance by the "singleton" design pattern.
It will always return the same instance for this class, which can be used for performance reasons and as a simple way to access instance methods which don't rely on instance data (e.g. the custom SilverStripe static handling).
        
                            
    __construct(resource $stream, int $contentLength, int $statusCode = null, string $statusDescription = null)
        
    
    HTTPStreamResponse constructor.
        
                            $this
    setProtocolVersion(string $protocolVersion)
        
    
    The HTTP version used to respond to this request (typically 1.0 or 1.1)
        
                            $this
    setStatusCode(int $code, string $description = null)
        
    
    No description
        
                            $this
    setStatusDescription(string $description)
        
    
    The text to be given alongside the status code ("reason phrase").
Caution: Will be overwritten by setStatusCode().
        
                            string
    getProtocolVersion()
        
    
    No description
        
                            int
    getStatusCode()
        
    
    No description
        
                            string
    getStatusDescription()
        
    
    No description
        
                            bool
    isError()
        
    
    Returns true if this HTTP response is in error
        
                            $this
    setBody(string $body)
        
    
    No description
        
                            string
    getBody()
        
    
    No description
        
                            $this
    addHeader(string $header, string $value)
        
    
    Add a HTTP header to the response, replacing any header of the same name.
        
                            string
    getHeader(string $header)
        
    
    Return the HTTP header of the given name.
        
                            array
    getHeaders()
        
    
    No description
        
                            $this
    removeHeader(string $header)
        
    
    Remove an existing HTTP header by its name, e.g. "Content-Type".
        
                            HTTPResponse
    redirect(string $dest, int $code = 302)
        
    
    No description
        
                            
    output()
        
    
    Send this HTTPResponse to the browser
        
                    protected        
    htmlRedirect()
        
    
    Generate a browser redirect without setting headers
        
                    protected        
    outputHeaders()
        
    
    Output HTTP headers to the browser
        
                    protected        
    outputBody()
        
    
    Output body of this response to the browser
        
                            bool
    isFinished()
        
    
    Returns true if this response is "finished", that is, no more script execution should be done.
Specifically, returns true if a redirect has already been requested
        
                            bool
    isRedirect()
        
    
    Determine if this response is a redirect
        
                            string
    __toString()
        
    
    The HTTP response represented as a raw string
        
                    protected        bool
    isSeekable()
        
    
    Determine if a stream is seekable
        
                            resource
    getStream()
        
    
    No description
        
                            $this
    setStream(resource $stream)
        
    
    No description
        
                            string
    getSavedBody()
        
    
    Get body prior to stream traversal
        
                    protected        mixed
    consumeStream(callable $callback)
        
    
    Safely consume the stream