Aug 18, 2012; 14:45
kimrvan
More Lasso 9 Types and Member Methods
Hi List,
I'm solidifying my understanding of Lasso 9's Types and Member Methods with the project below.
I'm trying to update Bil Corry's 'lp_header_nocache' tag on TagSwap to Lasso 9. I hate to mess up the Bil's code with an inferior revision, so I need some help.
I believe the code below has been updated to a point, but I'm unsure of the use of web_response.
<?LassoScript
/*----------------------------------------------------------------------------
(lp_header_nocache)
Via http header, sets the content to immediately expire, no caching.
Author: Bil Corry
Last Modified: Feb. 05, 2008
License: Public Domain
Description:
Via http header, sets the content to immediately expire, no caching.
Sample Usage:
lp_header_nocache; // that's it!
Downloaded from tagSwap.net on Nov. 25, 2010.
Latest version available from <http://tagSwap.net/lp_header_nocache>.
----------------------------------------------------------------------------*/
/* Via http header, sets the content to immediately expire, no caching */
// Define 'lp_header_nocache' type with data members ('header'), methods (ie. public),
// contraints (ie.string) and empty values (ie. = string)
// Reference at http://www.lassosoft.com/Language-Guide-Defining-Types
define lp_header_nocache => type {
data public headers::string = string
/* Not sure how to convert this:
-description='Via http header, sets the content to immediately expire, no caching.',
-priority='replace')
*/
// Define 'onCreate' member method with signature that does not require a
// parameter, but indicates a return type constraint, and subsequent code block
// Reference 'Member Methods' at http://www.lassosoft.com/Language-Guide-Defining-Methods
public onCreate()::string => { // Begin code block
// Retrieve process tag defined globally within Lasso
// See Lasso 8.6 Language Guide, Chapter 43 - Control Tags, Page Content Tag section
// .'header' = $__http_header__ // Lasso 8.6
.'headers' = web_response->headers // Lasso 9
#headers->replace('HTTP/1.0', 'HTTP/1.1')
#headers += 'Expires: Thu, 11 Jun 1998 13:17:30 GMT\r\n'
// Convert 'Last-Modified' to Greenwich Mean Time (GMT)
local('_date' = date(date->format('%q')))
local('zone_offBy' = #_date->asCopy->zoneOffset) // Difference with GMT in milliseconds
#zone_offBy += #_date->asCopy->dstOffset // Add difference with DST in milliseconds
#_date->add(-millisecond = #zone_offBy)
#headers += 'Last-Modified: ' + #_date->setFormat('%a, %d %b %Y %H:%M:%S') + ' GMT\r\n'
#headers += 'Cache-Control: no-store, no-cache, must-revalidate, no-transform, max-age=0, post-check=0, pre-check=0\r\n'
#headers += 'Pragma: no-cache\r\n'
if(!#headers->contains('vary:'))
#headers += 'Vary: *\r\n'
/if
if(!#headers->contains('ETag:'))
#headers += 'ETag: "'lasso_uniqueID'"\r\n'
/if
} // End onCreate method code block
}
?>
Thanks to all.
#############################################################
This message is sent to you because you are subscribed to
the mailing list Lasso
Lasso@lists.lassosoft.com
To unsubscribe, E-mail to: <Lasso-unsubscribe@lists.lassosoft.com>
Send administrative queries to <Lasso-request@lists.lassosoft.com>
Aug 18, 2012; 14:53
kimrvan
Re: More Lasso 9 Types and Member Methods
Aug 19, 2012; 05:16
Rick Draper
RE: More Lasso 9 Types and Member Methods
Aug 18, 2012; 16:31
Brad Lindsay
Re: More Lasso 9 Types and Member Methods
Aug 18, 2012; 18:10
kimrvan
Re: More Lasso 9 Types and Member Methods