Skip to main content

%CSP.StreamServer

Class %CSP.StreamServer Extends %CSP.Page [ System = 3 ]

The %CSP.StreamServer serves any stream data directly from InterSystems IRIS. It derives from %CSP.Page and implements the OnPage() and OnPreHTTP() methods.
You can control how the stream is sent using the stream's attributes, these attributes can be accessed via properties in the %CSP.CharacterStream and %CSP.BinaryStream, however you can also set these directly in any stream class. The attributes are:

  1. ContentType - Sets the %response.ContentType property
  2. CharSet - Sets the %response.CharSet property
  3. Expires - Sets the %response.Expires property
  4. ContentDisposition - Set the 'Content-Disposition' response header You can set the default charset to server up character files in using the global ^%SYS("CSP","DefaultFileCharset"), and if you need to define settings per extension (in uppercase) you can use ^%SYS("CSP","MimeFileClassify",$zcvt(ext,"U"))=$listbuild(type,bin,charset) where:
  5. type - Content Type value, e.g. 'text/javascript'
  6. bin - 1 if this is binary and 0 if this is a character file
  7. charset - For character files the charset to report in the charset header If nothing is defined then for character files we use the default charset associated with the file device in InterSystems IRIS.

Parameters

UseSession

Parameter UseSession As BOOLEAN = 0;

Stream serving does not need the session

Methods

OnPreHTTP

ClassMethod OnPreHTTP() As %Boolean

The OnPostHTTP() is called by the CSP dispatcher before the HTTP headers have been sent. Here, we check that the incoming STREAMOID value is valid, then we set the appropriate content type and content length values into the %response object (see %CSP.Request), in preparation for sending the image data in the OnPage().

OnPage

ClassMethod OnPage() As %Status

The OnPage() is called by the CSP dispatcher to generate the page content. For %CSP.StreamServer, since the content type is actually a stream, not HTML we simply write out the stream data.

GetOidForFile

ClassMethod GetOidForFile(file As %String) As %ObjectIdentity [ Internal ]

Get oid for file

FileClassify

ClassMethod FileClassify(ext As %String, ByRef type As %String, ByRef bin As %Boolean, ByRef charset As %String) As %Boolean

Classify a file type

ToHTTPDate

ClassMethod ToHTTPDate(h As %String) As %String

Convert a $H value into an HTTP date format. It assumes that $H is local time and converts it to UTC

FromHTTPDate

ClassMethod FromHTTPDate(hd As %String) As %String

Convert an HTTP date to a $HOROLOG format date, converts from UTC time to the local time.