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(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 page.

o.AppendHeader(lcHeaderKey,lcHeaderValue)

BasicAuthentication

This method creates a self contained HTTP request that asks the browser to
present the login dialog into which the user must type the username and
password. The password is then validated by the Web server typically
against the NT (or Windows) user database. The exact validation varies by
Web server - IIS uses the NT User database on the server.

o.BasicAuthentication(tcRealm, tcErrorText)

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 using a FileOpen dialog.

o.DownloadFile(lcFileName, lcContentType, lcFileDisplayName)

End

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

o.End()

ExpandPage

o.ExpandPage(lcPhysicalPath, lnPageParseMode)

ExpandScript

o.ExpandScript(tcPageName, tnMode, tvContentType, tlTemplateStr, llNoOutput)

ExpandTemplate

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

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

o.TransmitFile(lcFileName, lcContentType)

Write

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

o.Write(lcText, llNoOutput)

ContentType

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

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

Requirements

Assembly: wwPageResponse.prg

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