Processing Requests
EiffelWeb provides a complete set of features and interface which helps building a wide range of possible requests.
Basic CGI Handling
Accessing Environment Variables
Much of the information needed by CGI applications is made available via environment variables. Programs using EiffelWeb can access this information through the class CGI_ENVIRONMENT.
These variables are usually used for the following purposes:
- Getting information about the server itself
- Checking the client browser
- Restricting Access for specified Domains
- Ensuring User Authentication and Identifications
- Dealing with Cookies
Accessing Input Values
The browser sends in the In a stream containing the data relative to the user entry and selection at the applications starts. EiffelWeb stores each data element and its associated name within a Hash-Table, the feature
Sending answers to the browser
The response has to contain an HTTP header in order to be understood by the browser. Depending on the nature of the reply, an HTML page, a simple re-direction, an error notification, you will select different features and options. Your application must send at least a response header, indicating the status of the request if known. You may want to attach to it the text you wish to send back to the user. This text is usually written in HTML, so that it will display nicely on the user's browser; you can use for this purpose the class
Dealing with Cookies
You can access the cookies corresponding to a specific URL/domain thanks to the feature
To store a cookie on a machine, you can use the feature
Advanced Topics
EiffelWeb and Security
The information the server sends back may be confidential. Follow these steps to protect the page content:
- Create an HTML page, for example by using class HTML_PAGE.
- Store this page somewhere, with a random name.
- Create an instance of class
CGI_RESPONSE_HEADER and choose the secure redirect option. Then callsend_to_browser .
Complex Headers
The Eiffel-Web application has the possibility to send a selection of different HTTP headers. They can be found in class
Debugging facilities
Design by Contract is one of the greatest strengths of the Eiffel programming language. When you usually run your application from EiffelStudio, you are notified when an assertion is violated and the tool offers different options in order to be able to find out its sources (feature and class tools, object inspectors, etc). However this cannot be applied to an EiffelWeb application, since it has to be run on the server.
Therefore, EiffelWeb provides its own facilities for debugging. To test your classes at run-time, all you need to do is to set the Boolean feature True
in your root class (which should inherit from