This lesson will focus on the HTTP Handler API on the DataFlex side. In DataFlex code the HTTP Handler presents itself as a class, the cWebHttpHandler class. An object of this class is instantiated for the URLs that are to be handled. There can be multiple handlers within an application. This is configured using two properties: psPath and psVerbs. PsPath determines which URLs are handled, and psVerbs which filters out the request based on the type. The handling of the request is implemented by implementing the events of the class.
This example of the ACP handler shows the object being defined, and the simple HTML page that results.
psPath is set to “SimpleHTTP.” In the resulting URL localhost is shown, followed by the directory, and then finally what psPath was set to. psPaths are flexible, wildcards cannot be used but multiple levels can be used simultaneously. Backslashes cannot be used. psPath maps to an IIS configuration path.
The psVerb property is set to “*” by default, which means that it will handle any verb/request that comes in. It can be set to a single verb such as ‘GET,’ or set to a comma separated list of verbs. It is recommended to specify which verbs it is to handle.
An example of when this is important are the OPTION requests for cross domain calls. By default, OPTION requests are handled by IIS. If they are set with psVerbs, the requests are intercepted, and IIS is prevented from doing what it is intended to do; sending out 404 or 500 errors for example.
The Events that can be used:
peErrorType is another property that can be set on the HTTP handler. It defines the format of the errors that are sent back to the client that occur outside of the DataFlex code. Errors formats can be…
This property cannot be changed at runtime.