WebHub Object Pascal Components

Handling Checkboxes on Forms v3.250
It is no longer necessary or recommended to use .ckb and .keepckb commands to adjust checkbox input so the data goes into the BoolVars list.
Instead, use the OffOn flag in INPUTCHECKBOX|varName|OffOn|otherAttributes. This creates a combination hidden+visible pair for each checkbox with the checkbox data in the pWebApp.Session.StringVars array, containing '1' or '0' depending on the checkbox state. Use IFSTR to test the value (instead of IF). (See awhCheckboxTrue below for customizing the '1' and '0' strings.)
Alternatively, if you prefer to have the variables moved to BoolVars, use this new command on the form-data-receiving page: MOVETOBOOLVARS|varList. Example: MOVETOBOOLVARS|cbOne,cbTwo,cbThree. If you move the variables, you can continue to test them with IF and to toggle them on with CHECK.
In Delphi, you can use pWebApp.StringVarBool[variableName] to access a StringVar being treated as a boolean. The corresponding new WHTEKO commands are IFSTR and CHECKSTR.
Here is a regular expression that you can use to find old syntax in *.whteko files:
If you need to override the id attribute of the checkbox to something other than its name, upgrade to v3.255 or contact tech support for a way to patch v3.250-v3.254.
For example usage, see the FORM demo.
Source: htWebApp.pas
New global checkbox true/false strings v3.250
uses htmConst
The default strings are '1' and '0' for True and False.
The global names are awhCheckboxTrue and awhCheckboxFalse.
  // in any initialization section
  awhCheckboxTrue := 'Y'; // uses htmConst
  awhCheckboxFalse := 'N';
These strings are used with these WebHub commands INPUTCHECKBOX, IFSTR, CHECKSTR which need to treat "string" variables as boolean variables. If you had code looking for specific Y/N or Yes/No values, please set the constants as shown above.
INPUTSELECTCHECKBOX unsupported v3.250
Obsolete code relating to INPUTSELECTCHECKBOX has been removed.
EurekaLog7 support v3.250
new unit: ucEurekaLog7Interface.pas
CSSendException includes EurekaLog7 call stack when possible
TSharedInt32 v3.250
New on palette: TSharedInt32 // uses tpShareB
No longer on palette: TtpSharedInt32 // uses tpShareI
D24 Delphi 10.1 Berlin Supported v3.251
The latest Delphi compiler from Embarcadero, Delphi 10.1 "Berlin," is supported in WebHub v3.251.
Response.SimulateAppNotDefined v3.251
New method: pWebApp.Response.SimulateAppNotDefined
Shutdown command no longer supported v3.251
There is no longer any shutdown command supported.
Developers may call whadmin.exe to control instances.
Configuration about the shutdown command is ignored if present in XML files.
App state after Refresh v3.251
When the app is refreshed, its connect-to-Hub state is automatically reset. Normally this would mean resetting it to Idle so that additional page requests can be served immediately.
Long AppIDs, PageIDs and/or Commands v3.252
The URL limit has been increased to allow for long combinations of AppIDs, PageIDs and/or command strings.
Response.SimulateSituation v3.253
Use this method to simulate AppIDBusy, AppNotRunning, HubNotFound and UploadError, passing in the TwhSituationAbbrev from the following list.
  // uses webSysMsg
  TwhSituationAbbrev = (whsitAppIDBusy, whsitAppNotRunning, 
    whsitAppCoverPage, // takes extra parameters
    whsitRequestTimeout, // takes one parameter
	whsitHubNotFound, whsitUploadError, 
	whsitAppNotDefined, // customized in IIS Error Pages
For example syntax, please see pageid="pgTestSimulatedErrors" in the WebHubDemos svn repository.
NowUTC v3.253
The ucMsTime unit has a function named NowUTC which returns the Windows GetSystemTime as a Delphi TDateTme. The NowGMT function calls NowUTC and does not make any adjustments.
Please change all references in *.pas from NowGMT to NowUTC, and in *.whteko from YearGMT to YearUTC.
WebTimeUTC v3.258
CentralInfo.WebTimeUTC returns 'UTC' as the timezone rather than 'GMT'.
File upload v3.254
The parameters for the OnUploaded event have changed:
  TOnUploaded = procedure(Sender: TwhBasicApp;  // uses webBase
    const ServerKey: string;
    const UploadFileCount, UploadFileTotal: Integer;
    const FileName, FileType, FileSource: string;
    const FileSize: Int32; const FileTooBig: Boolean;
    var SaveAs: string; var KeepNow, KeepOnExit: Boolean) of object;
Error handling for file uploads which are too large has changed.
For files uploaded to WebHub pages that respond with JSON, as defined by the rules for WebHub system messages overrides, any error message will be provided immediately by the runner. Details about the error condition will be in http headers, for relatively easy access from JavaScript.
For files uploaded to non-json pages, i.e. normal dynamic HTML pages, the runner v3.254 will no longer provide the error response. Instead, control will flow through to the custom WebHub app, with the additional parameters listed above. Note especially FileTooBig which will be True when the file is too large.
In WebHub v3.248 through v3.253, there was a problem using INPUTSELECT with the multiple attribute. Only one selection would be saved. This problem has been fixed.
Source: webVars.pas
This adjustment can be patched into those earlier versions easily; please ask tech support.
TDirectoryWatch v3.255
Cromis.DirectoryWatch.pas is distributed with TPack and WebHub now.
BSD license. See comments in the file.
Project Identifier v3.255
WebHub applications compiled with TtpProject and running as-app (not as-service) may have been reporting themselves with a higher instance number than they should have. For example, the first instance might report itself to the Hub as instance #2. This has been fixed.
Source: tpProj.pas
This adjustment can be patched into those earlier versions easily; please ask tech support.
UTF8 string functions v3.255
The utf8 string functions have been moved from ucString.pas to ucString8.pas in TPack.
To compile with any of these functions, add ucString8 to your uses clause.
See also ucPos8.pas
Code64String BASE64 for AWS file upload v3.257
The Code64String command now takes some optional parameters which enable it to be used to create the BASE64 version of a Policy string for file upload to an AWS S3 bucket.
Source: htWebApp.pas
Requires D22+ (i.e. Delphi XE8 or later). The code will compile but not function in earlier versions of Delphi.
AWSSignature2 for AWS file upload v3.257
There is a new WHTEKO command, AWSSignature2, which can give you a SHA1 hmac signature suitable for use with AWS file upload.
Source: htWebApp.pas in WebHub, ucAWS_Security in TPack, ucAWS_S3_Upload in TPack
Requires D22+. This will compile in earlier versions of Delphi but the result will always be an empty array of bytes.
Sign URLs for download from AWS CloudFrontv3.258
See the showcase demo: 3AWSFileUpload.whteko.
Source: see new tpack units, ucAWS_Security.pas, ucAWS_S3_Upload.pas, ucAWS_CloudFront_PrivateURLs.pas
App Startupv3.258
App no longer attempts to respond before its "heartbeat" file has been written. This helps with problems with requests that arrive when the app is first starting or refreshing.
RejectSession bounces lessv3.258
RejectSession takes the surfer directly to the FrontDoor unless the requested PageID is in the SideDoorPageIDs list.
New property can be set from Delphi: pWebApp.Situations.SideDoorPageIDs (set in a handler that is called whenever the app refreshes). ZMAdmin configuration is pending.
Example: whdemo_Extensions.pas in WebHubDemos svn repo
This event had been passing in the PageID of the FrontDoor. Now it passes in the PageID that was requested by the surfer, so you can more easily decide to allow access to that pWebApp.Situations.FrontDoorPageID page.
The PageID is no longer set to the FrontDoor during DoOnNewSession in core WebHub. It had been set in DoOnNewSession, just before OnNewSession was called. This was a duplication of effort.
If you set a FrontDoor for your app, or have been using OnFrontDoorTriggered, please test that aspect of your site before deploying v3.258+.
Example: procedure TDemoHelperComponent.DemoFrontDoorTriggered in whdemo_Initialize.pas

The Hub

ZMAdmin config v3.251
ZMAdmin no longer prompts for anything relating to a shutdown command, including AppShuttingDown message details.
To maintain backwards compatibility within configuration version 4 ("cv004"), the XSD for WHCentralInfo and WHAppConfig have not changed. You may remove the shutdown settings from your XML files if you wish; even if you leave them in, they will be ignored at runtime.
whadmin 0 v3.251
whadmin.exe 0 is now a shortcut for whadmin app instances stop all.
Compiled with D24 v3.252
The hub.exe and whadmin.exe files are compiled with the latest version, Delphi 10.1 Berlin.
Optimized v3.255
Hub optimized to avoid threads communicating with each app instance.
Hub reviews connected apps every 15 seconds to make sure each is still running.

WebHub Runners

HTTP status 500.13 WHBusy v3.250
The runner uses a new technique (compared to wh v3.249) to decide when it is completely overloaded. The 500.13 WHBusy response should be rare now, except on extremely old/slow machines.
HTTP Connection: keep-alive v3.250
In v3.247..v3.249, certain responses such as AppNotRunning from the runner included a Connection: close header in the http prologue. This led to the page content being unavailable to IOS WebView. Fixed.
System Message Responses v3.250
The WriteSituationPage method does not write a BOM for the response file. This is critical when the content type is JSON and the last 3 bytes of the file contained JSON syntax rather than whitespace.
Situation for Invalid AppID v3.252
Situation AppNotDefined comes back with http status code 404. Previously it came back with status code 211.
Compiled with D24 v3.252
The runisa.dll file is compiled with the latest version, Delphi 10.1 Berlin.
HTTP status 500.12 WHStarting v3.252
When the IIS AppPool starts, the first request will go straight through. Requests that follow immediately, within the first 1000ms, will be rejected until the first request has had a chance to fully initialize the runner. During this early initialization time, a 500.12 http status error is returned for the rejected requests.
File upload v3.252
In fairly rare conditions, a bug in runisa.dll had prevented file upload from completing. Fixed.
Files must upload within 14 seconds, regardless of file size and content type. If you need to support slow uploads, make sure the allowed Shutdown time for your IIS AppPool is a few seconds longer, e.g. at least 17 seconds.
File upload v3.253
For uploaded files that exceed the maximum allowed size, the isapi runner will reject the upload as quickly as possible, after draining all the bytes sent by the client.
Note that the maximum allowed size is set as a property of the RunnerID in ZMAdmin.
Situation Http Header v3.253
The http header providing the situation abbreviation for all situations has been renamed from X-Status-Reason to X-Status-Situation.
Situation UploadError for file upload v3.253
Errors involving file-too-big and file-upload-too-slow will be returned as a new WebHub Situation called UploadError.
Depending on the type of file upload problem, an integer value reflecting either UploadMaxSizeKB or UploadMaxSeconds will be provided both as an HTTP header for use from JavaScript and as an expandable macro within a .whmsg file.
The HTTP header names will be: X-Status-UploadDetail (set to 'MaxSizeKB' or 'MaxSeconds') plus X-Status-UploadMaxSizeKB or X-Status-UploadMaxSeconds.
Developers should handle the file upload error reporting within their default .whmsg file.
To simulate this error, use pWebApp.Response.SimulateUploadError
  // uses htmlBase
    procedure SimulateUploadError(const IsTooBig: Boolean;
      const iMaxKB, iMaxSeconds: Integer);
Situation AppCoverPagev3.253
The 4 extra pieces of information available when an App is covered are now provided in HTTP headers for easier use from JavaScript. The header names are: X-Status-CoveredOnAt, X-Status-ExpectedMinutes, X-Status-ExpectedOnAt and X-Status-Reason.
Situation AppNotDefined v3.253
The runner sends a 404.4 response, where the content can be defined by the IIS custom error page for that status.
This enables a customized appearance based on web domain, which is important on shared servers.
cgi-bin status: on hold v3.254
The cgi-bin runner remains on hold. It should rematerialize for Apache before the end of June 2016.
RunnerID forces AppID v3.255
This feature is active now.
Timeout differs based on File Upload Configv3.256
The internal timeout in the runner varies depending on whether file upload is required.
When the maximum file upload size is 10kb or less, it is assumed that either file upload is not required or will be so fast that no extra time is required for data processing. In that case, the runner allows only a few seconds for data processing. This means that in a situation of high-CPU usage, the runner will exit relatively gracefully in less than 10 seconds total. This means that the IIS configuration for shutdown time can be safely set to 10 seconds.
When the maximum file upload size is more than 10kb, it is assumed that file upload is an active feature. In that case, the runner allows 24 seconds for data processing and the IIS configuration should allow 30 or more seconds for shutdown.
The default file upload size is 100kb.
The default IIS shutdown time is 90 seconds.
File upload size in KBv3.258
In v3.257, the file upload config was off by a factor of 1024 (kbytes vs bytes). In v3.258 it works as expected, based on the config setting with KB units.
Threadpool optimizedv3.258
Runner uses default TThreadPool.
Runner reports TThreadPoolStats when a several error condition is encountered. These statistics will appear as a Warning in the CodeSite log file.
D18 support endsv3.258
WebHub Components v3.258 are the last version to support Delphi compiler D18.
IPC API changev3.259
WebHub v3.259 runner is not compatible with an earlier Hub nor Components due to the addition of a field in the IPC data.
Please recompile custom WebHub EXEs with v3.259 when you use WebHub Runtime v3.259.
Tentatively: the runner timeout situation is NOT supported in v3.259. The http client may receive no response from the http server.
TTask.Run avoidedv3.259
Runner tasks are executed without calling TTask.Run and this avoids 99% of the status 500.12 and 500.13 errors that were troublesome in recent releases.