Class wwPageResponse

The wwPageResponse class is Web Connection's default Response class that replaces the original wwResponse class. This class has a more modern and leaner interface using standard mechanisms for setting the ContentType, adding headers, setting cookies, adding authentication and of course writing output. This new response class is a memory only class as it can set and update headers at any time during the Request lifetime.

At the lowest level the Write() method is used to generate output. You can use the ContentType property to set the content type for the request - things like text/hml (default) or application/json for example. You can use AppendHeader() to add any HTTP header to the response and AddCookie() to add a cookie. DownloadFile() and TransmitFile() let you efficiently serve content from disk.

Higher level methods include ExpandScript() and ExpandTemplate() to parse FoxPro code and expressions inside of HTML markup templates.

This class generates string based output that can be collected using the RenderHttpHeader() and Render() methods which return the header and body output respectively. Note that you can use wwPageResponse easily outside of Web Connection to build up HTTP responses.

Output of this class is limited to 16 megabytes due to FoxPro's string length limitations. You can use TransmitFile() or DownloadFile() to send larger content to file and then serve the file from disk over HTTP which allows for larger files and responses to be returned.

wwPageResponse in wwProcess Classes

wwProcess uses the wwPageResponse class to generate request HTTP output. wwPageResponse is this the default Response object which is equivalent to the following in the class header of your Process class:

cResponseClass = "wwPageRepsonse"

Backwards Compatibility with wwPageResponse40

Web Connection 6.0 and later removes many legacy features that existed on the original wwResponse class which may break old applications that are upgraded. Many of these legacy functions dealt with custom headers via a clumsy function and a number of output generation routines for form controls and various high level HTML constructs like ShowCursor() and DbfPopup(). All of this functionality is now available in more modular fashion in other places in the framework. Header manipuluation has been moved to Response.AppendHeader(), Authentication() and AddCookie(), while most of the HTML generation routines can now be found in much more flexible helpers in wwHtmlHelpers.

While we recommend you replace any legacy functionality with new features for consistency and much cleaner code, you can fall back to the wwPageResponse40 class which includes all the legacy features. To use this class simply change the wwProcess::cResponseClass in your custom Process class:

cResponseClass = "wwPageRepsonse40"

>
> This class should allow existing applications to use the new Page class functionality without any major changes.

Remarks

Any ~/ virtual relative paths in the final output are automatically replaced to use the Process.GetUrlBasePath() value. So any reference of < script src="~/scripts/jquery.js > fixes up to the proper virtual path like: < script src="/wconnect/scripts/jquery.js" >.

Class Members

MemberDescription

AddCacheHeader

Adds an HTTP header that provides for Maximum Caching Capabilities

o.AddCacheHeader(lnExpirationSeconds)

AddCookie

Adds a cookie to the current Response headers.

o.AddCookie(toCookie | tcCookie,tcValue, tcPath,tcExpire, tlHttpOnly, tlSecure)

AddForceReload

Adds maximum Cache Expiration headers to the current HTTP request. Essentially this forces the request to always be reloaded rather than cached.

o.AddForceReload()

AppendHeader

Adds an HTTP Header to the current response.

o.AppendHeader(lcHeaderKey,lcHeaderValue)

Authentication

Generic, self-contained response for Authentication (HTTP 401 Status) by the server.

o.Authentication(tcErrorText, llBasicAuth, llWindowsAuth)

BinaryWrite

Same as Write() but provided for ASP.NET compatibility.

o.BinaryWrite(lcText)

Clear

Clears the content of the current Response output.

o.Clear()

DocFooter

Writes out the </body> and </html> tags at the end of an HTML page. Optionally allows to write out a block of HTML prior to these tags.

o.DocFooter(lcHtml, llNoOutput)

DocHeader

Creates an HTML document header, <head> section and <body> tag.

o.DocHeader(lcTitle, lcStyleSheets, lcHeaderItems, llNoOutput)

DownloadFile

Downloads a file directly from disk to the client and displays it on the client using FileOpen dialog rather than opening in the browser. This function specifically provides a file name to the browser and forces the browser to open the file rather than displaying it.

o.DownloadFile(lcFileName, lcContentType, lcFileDisplayName)

End

Ends the current response. Any further output send to the Response object is ignored.

o.End()

ExpandPage

Executes a Web Control Framework page by providing a physical path to the page allowing for parsing, compiling and running the page.

o.ExpandPage(lcPhysicalPath, lnPageParseMode)

ExpandScript

The ExpandScript method method is used to expand script pages that contain FoxPro expressions and Code blocks using Active Server like syntax. The method generates a fully self contained HTML page/HTTP output which includes an HTTP header.

o.ExpandScript(tcPageName, tnMode, tvContentType, tlReturnAsString)

ExpandTemplate

The ExpandTemplate method is used to expand template pages that contain FoxPro expressions using Active Server like syntax using < % expression() % > and < % Command % > syntax inside of HTML documents. The method generates a fully self contained HTML page/HTTP output which includes an HTTP header.

o.ExpandTemplate(tcPageName, tcContentType, tlTemplateString, tlReturnAsString)

FastWrite

Direct write to the output stream. This method directly writes into the response stream and bypasses any checks and flags. So it doesn't check for the ResponseEnded flag for example.

o.FastWrite(lcText)

Redirect

HTTP Redirection allows you redirect the current request to another URL. A common scenario is for login operations where the user is trying to access functionality before he's logged in. When the request comes in you can redirect the user to the Login page first.

o.Redirect(lcUrl,llPermanent)

Render

This method is called to return the output of the Response object. It combines the headers and the body together and returns the entire response.

o.Render()

TransmitFile

Allows sending large files directly from disk, bypassing FoxPro processing and instead directly serving the file very efficiently. By doing so you can easily send very large files and bypass FoxPro's 16mb memory limitations and without tying a FoxPro Web Connection instance.

o.TransmitFile(lcFileName, lcContentType, lcFileDisplayName)

Write

Raw HTTP output function. Writes directly to the Response stream/string.

o.Write(lcText, llNoOutput)

WriteFullResponse

Writes full response content into the Response output, replacing any existing output.

o.WriteFullResponse(lcText, llNoOutput)

ContentType

Sets the content type for the current HTTP response. This value defaults to text/html if not set.

Cookies

Cookies collection that contains multiple cookies that are set for the current request. The cookies are written at the end when the headers are created and written.

Encoding

Sets the content encoding for the page for text content.

Expires

The number of minutes before the page is expired.

GZipCompression

If set to .T. automatically encodes the Response output to GZip compressed format. When set Web Connection automatically checks whether the client supports GZip compression and only compresses content if it does.

Headers

A collection of individual HTTP headers that are to be added to the request header. The Headers of the Response can be set at any time during the request as they are cached and written at the end of the request.

RawHeaders

This is the low level string that is used to hold any RAW headers you want to add to a request. This is an override to Headers.Add() to allow for any headers or content that doesn't follow the name/value syntax of headers.

ResponseEnded

Set to turn off output that follows called by the Write method. This flag is set by Response.End() so you usually should not have to set this explicitly. However, you can use it to check whether the Response object is active.

Status

Allows you to specify the Response Status Code. The status code is the status number and message that follows the HTTP protocol.

Requirements

Assembly: wwPageResponse.prg

© West Wind Technologies, 1996-2024 • Updated: 02/26/16
Comment or report problem with topic