...Table of Contents... Ada Web Server ************** Introduction ************ `AWS' stand for Ada Web Server. It is an Ada implementation of the `HTTP/1.1' protocol as defined in the RFC 2616 from June 1999. The goal is not to build a full Web server but more to make it possible to use a Web browser (like Internet Explorer, or Netscape Navigator) to control an Ada application. As we'll see later it is also possible to have two Ada programs exchange informations via the `HTTP' protocol. This is possible as `AWS' also implement the client side of the HTTP protocol. Moreover with this library it is possible to have more than one server in a single application. It is then possible to export different kind of services by using different `HTTP' ports, or to have different ports for different services priority. Client which must be served with a very high priority can be assigned a specific port for example. As designed, `AWS' big difference with a standard `CGI' server is that there is only one executable. A `CGI' server has one executable for each request or so, this becomes a pain to build and to distribute when the project gets bigger. We will also see that it is easier with `AWS' to deal with session data. `AWS' support also `HTTPS' (secure `HTTP') using `SSL'. This is based on `OpenSSL' a very good and Open Source SSL implementation. Major supported features are: * HTTP implementation * HTTPS (Secure HTTP) implementation based on SSLv3 * Template Web pages (separate the code and the design) * Web Services - SOAP based * WSDL support (generate stub/skeleton from WSDL documents) * Basic and Digest authentication * Transparent session handling * File upload * Server push * SMTP / POP (client API) * LDAP (client API) * Embedded resources (full self dependant Web server) * Complete client API, including HTTPS * Web server activity log Building AWS ************ Requirements ============ `AWS' has been mainly developed with `GNAT' on Windows NT and built and tested many times on `GNU/Linux', it should be fairly portable across platforms. To build `AWS' you need: * GNU/Ada (GNAT compiler) ; `AWS' uses some `GNAT' specific packages and we have no plan to support another compiler at this point. It is too much work for us to check if `AWS' compiles to other compilers anyway. To build this version you need at least `GNAT 3.15'. On Windows you must also install `GNATWin' (Windows specific package). * a socket binding (optional) ; `GNAT.Sockets' is the default socket implementation used. It is possible to use `AdaSockets' (`AdaSockets' was used in AWS v 1.2) and in this case you must install the `AdaSockets' package. On Windows you must use the one distributed at which is a Win32 port (done by Dmitriy Anisimkov) of the ENST version. On UNIX you must use the socket binding from ENST . * a POSIX binding - Interface to the underlying OS services (optional) ; On Windows you can use the one distributed at: . On UNIX look for the Florist package at . * OpenSSL (optional) ; OpenSSL is an Open Source toolkit implementing the Secure Sockets Layer (SSL v2 and v3) and much more. You'll find libraries for Win32 into this distribution. For other platforms just download the OpenSSL source distribution from and build it. * OpenLDAP (optional) ; OpenLDAP is an Open Source toolkit implementing the Lightweight Directory Access Protocol. If you want to use the `AWS/LDAP' API on UNIX based systems, you need to install properly the `OpenLDAP' package. On Windows you don't need to install it as the `libldap.a' library will be built by `AWS' and will use the standard Windows `LDAP DLL' `wldap32.dll'. You can download OpenLDAP from . AWS.OS_Lib ========== The `AWS.OS_Lib' has 3 implementations. One using `POSIX', one using `GNAT.OS_Lib' and one using direct `Win32' calls. This last one is not anymore supported in this version. Contribution is welcome of course. GNAT.OS_Lib implementation Version using `GNAT.OS_Lib' is GNAT dependent and will run on whatever OS GNAT has be ported to. This is the default implementation used. $ make gnat_oslib POSIX implementation Version with `POSIX' is compiler and OS independent (well if you have a `POSIX' implementation for your OS). Check out `Florist' which is available on many `UNIX' and the version for Win32 is available on . $ make posix_oslib Win32 implementation (not anymore supported) Version for Win32 should be usable by any Ada compiler for Windows 95/98/NT/2000/XP. $ make win32_oslib AWS.Net.Std =========== This package is the standard (non-SSL) socket implementation. It exists different implementation of this package: GNAT implementation Version based on `GNAT.Sockets', is `GNAT' dependent and will run on whatever OS `GNAT' has be ported to. This is the default implementation used. To select this implementation just do: $ make gnatsockets AdaSockets implementation Version using `AdaSockets' packages. This was the default implementation used up to AWS 1.2. To select this implementation just do: $ make adasockets Building ======== When you have built and configured all libraries you must either set ADA_INCLUDE_PATH and ADA_OBJECTS_PATH (for `GNAT') to point to the right directories or update the ADASOCKETS, XMLADA and INSTALL variables in the top `makefile.conf'. You should have a look at file `INSTALL' for installation instructions. At this point you can build `AWS' with: $ make build Note that by default `AWS' demos will be built without `SSL' support except on Windows. If you want to build the demos with `SSL' on UNIX (in this case you must have `libssl.a' and `libcrypto.a' available on your platform), open `makefile.conf' and set the MODE variable to ssl. Then rebuild with: $ make build What is important to understand is that `AWS SSL' support is selected at link time and not at configure time. It is is possible to build `AWS' in debug mode by setting DEBUG make's variable in `makefile.conf', or just: $ make build DEBUG=1 Others make's targets are: `build_lib' Build AWS library only. `build_tools' Build AWS tools only. `build_demos' Build AWS demos only. For example, if you use `GNAT' and want to use the `GNAT.Sockets' implementation, you can build and install AWS with (you do not need to edit the makefile.conf): $ make build $ make install INSTALL=/opt Demos ===== During the build, the `AWS' library and demos will be compiled. The demos are a good way to learn how to use `AWS'. Yet to learn all features in `AWS' you'll need to read the documentation. Here are a short description of the demos: `agent' A program using the AWS client interface. This simple tool can be used to retrieve Web page content. It supports passing through a proxy with authentication and basic authentication on the Web site. `auth' A simple program to test the Web Basic and Digest authentication feature. `com_1' `com_2' Two simples program that uses the AWS communication service. `dispatch' A simple demo using the dispatcher facility. *note URI dispatcher::. `hello_world' The famous Hello World program. This is a server that will always return a Web page saying "Hello World!". `main' `hotplug' A simple test for the hotplug feature. `res_demo' A demo using the resource feature. This Web Server embedded a `PNG' image and an `HTML' page. The executable is self contained. `runme' A complete example that test many `AWS' features. If this test runs fine on your platform, `AWS' is certainly ok. `split' A demo for the transient pages and page splitter AWS's feature. Here a very big table is split on multiple pages. A set of links can be used to navigate to the next or previous page or to access directly to a given page. `test_jabber' A simple Jabber command line client to check the presence of a JID (Jabber ID). This uses the Jabber API, *note AWS.Jabber::. `test_ldap' A simple LDAP demo which access a public LDAP server and display some information. `text_input' A simple demo which handle textarea and display the content. `vh_demo' Two servers on the same machine... virtual hosting demo. *note Virtual host dispatcher::. `web_mail' A simple Web Mail implementation that works on a POP mailbox. `ws' A static Web page server and push enabled server. `wps' A very simple static Web page server based on `AWS.Services.Page_Server'. *note Static Page server::. `zdemo' A simple demo of the Gzip content encoding feature. If `XMLAda' is installed it is possible to build the `SOAP' binding and the `SOAP' demos, for this just type: $ make build_soap There is four demos: `soap_client' `soap_server' A simple client/server program to test the `SOAP' protocol. `soap_svs' A server that implements the seven `SOAP' procedures for the validation suite on . This demo can be used to validate `AWS/SOAP' on your platform. `soap_cvs' The client `SOAP' program that test all seven `SOAP' procedure of the above server. In each case you'll certainly have to edit the makefile to correctly set the include path for the libraries `POSIX', `OpenSSL', `Socket' and `XMLAda'. For more information, look at the makefiles. Installing ========== When the build is done you must install `AWS' at a specific location. The target directory is defined with the INSTALL `makefile.conf' variable. The default value is your home directory. To install: $ make install To install `AWS' into another directory you can either edit `makefile.conf' and set INSTALL to the directory you like to install `AWS' or just force the make `INSTALL' variable: $ make install INSTALL=/opt Now you are ready to use `AWS' ! Using AWS ********* Setting up environment ====================== Using environment variables --------------------------- After installing `AWS' you must set the build environment to point the compiler to the right libraries. First let's say that `AWS' has been installed in `awsroot' directory. This can be done automatically for the `GNAT' compiler by using the `/set-aws.sh' on UNIX or `\set-aws.cmd' on Windows. If you pefer setting the environment yourself here is how to do with `GNAT'. spec files The spec files are installed in `/include'. Add this path into ADA_INCLUDE_PATH or put it on the command line `-aI/include'. components `AWS' uses some components they are installed in `/components'. Add this path into ADA_INCLUDE_PATH or put it on the command line `-I/components'. libraries The GNAT library files (`.ali') and the `AWS' libraries (`libaws.a') are installed into `/lib'. Add this path into ADA_OBJECTS_PATH or put it on the command line `-aO/lib'. Furthermore for `gnatlink' to find the libraries you must add the following library path option on the `gnatmake' command line `-largs -L/lib -laws'. Note that to build SSL applications you need to add `-lssl -lcrypto' on gnatmake's `-largs' section. external libraries You must do the same thing for all external libraries that you will be using. For example you'll have to point `GNAT' to the `AdaSockets' libraries and pass `-ladasockets' on the gnatmake's `-largs' section. The same apply if you have built `AWS' with `POSIX' or with `SSL' support. Using GNAT Project Files ------------------------ The best solution is to use the installed GNAT Project File `aws.gpr'. This is supported only for `GNAT 5.01' or above. You must have installed `XMLAda' with project file support too. If this is the case just set the ADA_PROJECT_PATH variable to point to the `AWS' and `XMLAda' install directories. From there you just have to with the `AWS' project file in your GNAT Project file, nothing else to set. with "aws"; project Simple is for Main use ("prog.adb"); for Source_Dirs use ("."); for Object_Dir use "."; end Simple; If your application must support SSL, you have to link against the `-lcrypto' and `-lssl' libraries. Add a package `Linker' in your project file, something like: package Linker is for Default_Switches ("Ada") use ("-lcrypto", "-lssl"); end Linker; See the GNAT User's Guide for more information about GNAT Project Files. Basic notions ============= `AWS' is not a Web Server like IIS or Apache, it is a component to embedded HTTP protocol in an application. It means that it is possible to build an application which can also answer to a standard browser like Internet Explorer or Netscape Navigator. Since `AWS' provides support client and server HTTP protocol, applications can communicate through the HTTP channel. This give a way to build distributed applications, *Note AWS.Client::. An application using `AWS' can open many `HTTP' channels. Each channel will use a specific port. For example, it is possible to embedded many `HTTP' and/or many `HTTPS' channels in the same application. Building an AWS server ---------------------- To build a server you must: 1. declare the HTTP Web Server WS : AWS.Server.HTTP; 2. Start the server You need to start the server before using it. This is done by calling `AWS.Server.Start' (*Note AWS.Server::.) procedure Start (Web_Server : in out HTTP; Name : in String; Callback : in Response.Callback; Max_Connection : in Positive := Def_Max_Connect; Admin_URI : in String := Def_Admin_URI; Port : in Positive := Def_Port; Security : in Boolean := False; Session : in Boolean := False; Case_Sensitive_Parameters : in Boolean := True; Upload_Directory : in String := Def_Upload_Dir); - Start the Web server. It initialize the Max_Connection connections - lines. Name is just a string used to identify the server. This is used - for example in the administrative page. Admin_URI must be set to enable - the administrative status page. Callback is the procedure to call for - each resource requested. Port is the Web server port. If Security is - set to True the server will use an HTTPS/SSL connection. If Session is - set to True the server will be able to get a status for each client - connected. A session ID is used for that, on the client side it is a - cookie. Case_Sensitive_Parameters if set to False it means that the CGI - parameters name will be handled without case sensitivity. Upload - directory point to a directory where uploaded files will be stored. `Start' takes many parameters: Web_Server this is the Web server to start. Name This is a string to identify the server. This name will be used for example in the administrative status page. Callback This is the procedure to call for each requested resources. In this procedure you must handle all the possible URI that you want to support. (see below). Max_Connection This is the maximum number of simultaneous connections. It means that Max_Connection client's browsers can gets answer at the same time. This parameter must be changed to match your needs. A medium Web server will certainly need something like 20 or 30 simultaneous connections. Admin_URI This is a special URI recognized internally by the server. If this URI is requested the server will return the administrative page. This page is built using a specific template page (default is `aws_status.thtml') *note Status page::. The administrative page returns many information about the server. It is possible to configure the server via two configuration files *Note Configuration options::. Port This is the port to use for the Web server. You can use any free port on your computer. Note that on some OS specific range could be reserved or needs specials privileges (port 80 on Linux for example). Security If Security is set to True the server will use an HTTPS/SSL connection. This part uses the `OpenSSL' library. Session If Session is set to true the server will keep a session ID for each client. The client will be able to save and get variables associated with this session ID. Case_Sensitive_Parameters If set to True the CGI name parameters will be handled without using the case. Note that there is other `Start' routines which support other features. For example there is a `Start' routine which use a dispatcher routine instead of the simple callback procedure. *note AWS.Server::. And there is also the version using a `Config.Object' which is the most generic one. 3. provides a callback procedure The callback procedure has the following prototype: function Service (Request : in AWS.Status.Data) return AWS.Response.Data; This procedure receive the request status. It is possible to retrieve information about the request through the `AWS.Status' API (*Note AWS.Status::.). For example, to know what URI has been asked: URI : constant String := AWS.Status.URI (Request); if URI = "/whatever" then ... end if; Then this function should return an answer using one of the constructors in `AWS.Response' (*Note AWS.Response::.). For example, to return an HTML message: AWS.Response.Build (Content_Type => "text/html", Message_Body => "

just a demo"); It is also possible to return a file. For example, here is the way to return a PNG image: AWS.Response.File (Content_Type => "image/png", Filename => "adains.png"); Note that the main procedure should exit only when the server is terminated. For this you can use the `AWS.Server.Wait' service. A better solution is to use a template engine like Templates_Parser to build the HTML Web Server answer. Templates_Parser module is distributed with this version of AWS. For the latest version see . Callback procedure ------------------ The callback procedure is the user's code that will be called by the AWS component to get the right answer for the requested resource. In fact AWS just open the HTTP message, parsing the HTTP header and it builds an object of type `AWS.Status.Data'. At this point it calls the user's callback procedure, passing the object. The callback procedure must returns the right response for the requested resources. Now AWS will just build up the HTTP response message and send it back to user's browser. But what is the resource ? Indeed in a standard Web development a resource is either a static object - an HTML page, an `XML' or `XSL' document - or a `CGI' script. With `AWS' a resource is just a string to identify the resource, it does not represent the name of a static object or `CGI' script. So this string is just an internal representation for the resource. The callback procedure must be implemented to handle each internal resource and return the right response. Let's have a small example. For example we want to build a Web server that will answer "Hello World" if we ask for the internal resource /hello, and must answer "Hum..." otherwise. with AWS.Response; with AWS.Server; with AWS.Status; procedure Hello_World is WS : AWS.Server.HTTP; function HW_CB (Request : in AWS.Status.Data) return AWS.Response.Data is URI : constant String := Status.URI (Request); begin if URI = "/hello" then return AWS.Response.Build ("text/html", "

Hello world !"); else return AWS.Response.Build ("text/html", "

Hum..."); end if; end HW_CB; begin AWS.Server.Start (WS, "Hello World", Callback => HW_CB'Unrestricted_Access); delay 30.0; end Hello_World; Now of course the resource internal name can represent a file on disk. It is not mandatory but it is possible. For example it is perfectly possible to build with AWS a simple page server. As an example, let's build a simple page server. This server will returns files in the current directory. Resources internal name represent an HTML page or a GIF or PNG image for example. This server will return a 404 message (Web Page Not Found) if the file does not exist. Here is the callback procedure that implement such simple page server: function Get (Request : in AWS.Status.Data) return AWS.Response.Data is URI : constant String := AWS.Status.URI (Request); Filename : constant String := URI (2 .. URI'Last); begin if OS_Lib.Is_Regular_File (Filename) then return AWS.Response.File (Content_Type => AWS.MIME.Content_Type (Filename), Filename => Filename); else return AWS.Response.Acknowledge (Messages.S404, "

Page '" & URI & "' Not found."); end if; end Get; Form parameters --------------- Form parameters are stored into a table of key/value pair. The key is the form input tag name and the value is the content of the input field as filled by the user. Enter your name

"
Note that as explained above *note Callback procedure::, the resource described in `ACTION' is just an internal string representation for the resource. In this example there is two form parameters: name The value is the content of this text field as filled by the client. go The value is "Ok". There is many functions (in `AWS.Parameters') to retrieve the tag name or value and the number of parameters. Here are some examples: function Service (Request : in AWS.Status.Data) return AWS.Response.Data is P : constant AWS.Parameters.List := AWS.Status.Parameters (Request); ... `AWS.Parameters.Get (P, "name")' Returns the value for parameter named name `AWS.Parameters.Get_Name (P, 1)' Returns the string "name". `AWS.Parameters.Get (P, 1)' Returns the value for parameter named name `AWS.Parameters.Get (P, "go")' Returns the string "Ok". `AWS.Parameters.Get_Name (P, 2)' Returns the string "go". `AWS.Parameters.Get (P, 2)' Returns the string "Ok". `Request' is the `AWS' current connection status passed to the callback procedure. And `P' is the parameters list retrieved from the connection status data. For a discussion about the callback procedure *Note Building an AWS server::. Distribution of an AWS server ----------------------------- The directory containing the server program must contain the following files if you plan to use a status page *Note Status page::. `aws_status.thtml' The template HTML file for the `AWS' status page. `aws_logo.png' The `AWS' logo displayed on the status page. `aws_up.png' The `AWS' hotplug table up arrow. `aws_down.png' The `AWS' hotplug table down arrow. Note that these filenames are the current `AWS' default. But it is possible to change those defaults using the configuration files *note Configuration options::. Building answers ================ We have already seen, in simple examples, how to build basic answers using `AWS.Response' API. In this section we present all ways to build answers from basic support to the more advanced support like the compressed memory stream response. Redirection ----------- A redirection is a way to redirect the client's browser to another URL. Client's won't notice that a redirection has occurs. As soon as the browser has received the response from the server it will retrieve the page as pointed by the redirection. return Response.URL (Location => "/use-this-one"); New location for a page ----------------------- User will receive a Web page saying that this page has moved and eventually pointing to the new location. return Response.Moved (Location => "/use-this-one"; Message => "This page has moved, please update your reference"); Authentication required ----------------------- For protected pages you need to ask user to enter a password. *note Authentication::. Sending back an error message ----------------------------- `Acknowledge' can be used to send back error messages. There is many kind of status code, see `Message.Status_Code' definition. Together with the status code it is possible to pass textual error message in `Message_Body' parameter. return Response.Acknowledge (Status_Code => Messages.S503, Message_Body => "Can't connect to the database, please retry later.", Content_Type => MIME.Text_Plain); Response from a string ---------------------- This is the simplest way to build a response object. There is two constructors in `AWS.Response', one based on a standard string and one for Unbounded_String. return Response.Build (MIME.Text_HTML, "My answer"); The Build routine takes also a status code parameter to handle errors. By default this code is `Messages.S200' which is the standard HTTP status (no error encountered). The other parameter can be used to control caches. *note AWS.Response::. Response from a Stream_Element_Array ------------------------------------ This is exactly as above but the Build routine takes a `Stream_Element_Array' instead of a string. Response from a file -------------------- To build a `File' response there is a single constructor named `File'. This routine is very similar to the one above except that we specify a filename as the response. return Response.File (MIME.Text_HTML, "index.html"); Again there parameters to control the status code and cache. No check on the filename is done at this point, so if `index.html' does not exit no exception is raised. The server is responsible to check for the file and to properly send back the 404 message if necessary. Note that this routine takes an optional parameter named `Once' that is to be used for temporary files created on the server side for the client. With `Once' set to `True' the file will be deleted by the server after sending it. Response from a stream ---------------------- Sometimes it is not possible (or convenient) to build the response in memory as a string object for example. Streams can be used to workaround this. The constructor for such response is again very similar to the ones above except that instead of the data we pass an handle to a `Resources.Streams.Stream_Type' object. The first step is to build the stream object. This is done by deriving a new type from `Resources.Streams.Stream_Type' and implementing three abstract procedures. `Read' Must return the next chunk of data from the stream. Note that initialization if needed are to be done there during the first call to read. `End_Of_File' Must return True when there is no more data on the stream. `Close' Must close the stream and for example release all memory used by the implementation. The second step is to build the response object: type SQL_Stream is new Resources.Streams.Stream_Type; Stream_Object : SQL_Stream; procedure Read (...) is ... function End_Of_File (...) return Boolean is ... procedure Close (...) is ... return Response.Stream (MIME.Text_HTML, Stream_Object); Note that in some cases it is needed to create a file containing the data for the client (for example a tar.gz or a zip archive). But there is no way to properly remove this file from the file system as we really don't know when the upload is terminated when using the `AWS.Response.File' constructor. To solve this problem it is possible to use a stream as the procedure `Close' is called by the server when all data have been read. In this procedure it is trivial to do the necessary clean-up. Response from a memory stream ----------------------------- This is an implementation of the standard stream support described above. In this case the stream is in memory and built by adding data to it. To create a memory stream just declare an object of type `AWS.Resources.Streams.Memory.Stream_Type'. When created, this memory stream is empty, using the `Streams.Memory.Append' routines it is possible to add chunk of data to it. It is of course possible to call `Append' as many times as needed. When done just return this object to the server. Data : AWS.Resources.Streams.Memory.Stream_Type; Append (Data, Translator.To_Stream_Element_Array ("First chunk")); Append (Data, Translator.To_Stream_Element_Array ("Second chunk...")); ... return Response.Stream (MIME.Text_HTML, Data); Note that you do not have to take care of releasing the allocated memory, the default `Close' routine will do just that. Response from a compressed memory stream ---------------------------------------- This is a slight variant of the standard memory stream described above. In this case the stream object must be declared as a `AWS.Resources.Streams.Memory.ZLib.Stream_Type'. The ZLib stream object must be initialized to enable the compression and select the right parameters. This is done using the `AWS.Resources.Streams.Memory.ZLib.Deflate_Initialize' routine which takes many parameters to select the right options for the compression algorithm, all of them have good default values. When initialized the compressed stream object is used exactly as a standard stream. Data : AWS.Resources.Streams.Memory.ZLib.Stream_Type; Deflate_Initialize (Data); Append (Data, Translator.To_Stream_Element_Array ("First chunk")); Append (Data, Translator.To_Stream_Element_Array ("Second chunk...")); ... return Response.Stream (MIME.Text_HTML, Data); Note that there is the reverse implementation to decompress a stream. *note AWS.Resources.Streams.Memory.ZLib::. It's usage is identical. Split page ---------- `AWS' has a specific high level service to split a large response into a set of pages. For more information *note Split pages::. Configuration options ===================== To configure an `AWS' server it is possible to use a configuration object. This object can be set using the `AWS.Config.Set' API or initialized using a configuration file. Configuration files are a way to configure the server without recompiling it. Each application can be configured using two configurations files: `aws.ini' This file is parsed first and corresponds to the configuration for all AWS server runs in the same directory. `.ini' This file is parsed after `aws.ini'. It is possible with this initialization file to have specific settings for some servers. Furthermore, it is possible to read a specific configuration file using the `AWS.Config.Ini.Read' routine. *note AWS.Config.Ini::. Current supported options are: `Accept_Queue_Size (positive)' This is the size of the queue for the incoming requests. Higher this value will be and less "connection refused" will be reported to the client. The default value is 64. `Admin_URI (string)' This is the URI to call the administrative page. This can be used when calling `AWS.Server.Start'. The default is `'. `Certificate (string)' Set the certificate file to be used with the secure servers. The default is `cert.pem'. `Case_Sensitive_Parameters (boolean)' If set to `True' the `HTTP' parameters are case sensitive. The default value is TRUE. `Check_URL_Validity (boolean)' Server have to check URI for validity. For example it checks that an URL does not reference a resource above the Web root. The default is TRUE. `Cleaner_Wait_For_Client_Timeout (duration)' Number of seconds to timeout on waiting for a client request. This is a timeout for regular cleaning task. The default is 80.0 seconds. `Cleaner_Client_Header_Timeout (duration)' Number of seconds to timeout on waiting for client header. This is a timeout for regular cleaning task. The default is 20.0 seconds. `Cleaner_Client_Data_Timeout (duration)' Number of seconds to timeout on waiting for client message body. This is a timeout for regular cleaning task. The default is 28800.0 seconds. `Cleaner_Server_Response_Timeout (duration)' Number of seconds to timeout on waiting for client to accept answer. This is a timeout for regular cleaning task. The default is 28800.0 seconds. `Directory_Browser_Page (string)' Specify the filename for the directory browser template page. The default value is `aws_directory.thtml'. `Down_Image (string).' The name of the down arrow image to use in the status page. The default is `aws_down.png'. `Error_Log_Filename_Prefix (string)' This is to set the filename prefix for the log file. By default the log filename prefix is the program name (without extension) followed by "_error". `Error_Log_Split_Mode [None/Each_Run/Daily/Monthly]' It indicates how to split the error logs. Each_Run means that a new log file is used each time the process is started. Daily and Monthly will use a new log file each day or month. The default is NONE. `Exchange_Certificate (boolean)' If set to True it means that the client will be asked to send its certificate to the server. The default value is FALSE. `Force_Wait_For_Client_Timeout (duration)' Number of seconds to timeout on waiting for a client request. This is a timeout for urgent request when resources are missing. The default is 2.0 seconds. `Force_Client_Header_Timeout (duration)' Number of seconds to timeout on waiting for client header. This is a timeout for urgent request when resources are missing. The default is 3.0 seconds. `Force_Client_Data_Timeout (duration)' Number of seconds to timeout on waiting for client message body. This is a timeout for urgent request when resources are missing. The default is 10800.0 seconds. `Force_Server_Response_Timeout (duration)' Number of seconds to timeout on waiting for client to accept answer. This is a timeout for urgent request when resources are missing. The default is 10800.0 seconds. `Free_Slots_Keep_Alive_Limit (positive)' This is the minimum number of remaining free slots to enable keep-alive HTTP connections. For heavy-loaded HTTP servers, the Max_Connection parameter should be big enough, and Free_Slots_Keep_Alive_Limit should be about 1-10% of the Max_Connection parameter depending on the duration of the average server response. Longer is the average time to send back a response bigger Free_Slots_Keep_Alive_Limit should be. The default is 1. `Hotplug_Port (positive)' This is the hotplug communication port needed to register and un-register an hotplug module. The default value is 8888. `Key (string)' Set the RSA key file to be used with the secure servers. The default file is `'. `Line_Stack_Size (positive)' The HTTP lines stack size. The stack size must be adjusted for each applications depending on the use of the stack done by the callback procedures. The default is 1 376 256. `Log_File_Directory (string)' This is to set the directory where log file must be written. This parameter will be used automatically by `AWS.Log' if logging facility is enabled. By default log files are written in the current directory. The default is `./'. `Log_Filename_Prefix (string)' This is to set the filename prefix for the log file. By default the log filename prefix is the program name (without extension). `Log_Split_Mode [None/Each_Run/Daily/Monthly]' It indicates how to split the logs. Each_Run means that a new log file is used each time the process is started. Daily and Monthly will use a new log file each day or month. The default is NONE. `Logo (string).' The name of the logo image to use in the status page. The default is `aws_logo.png'. `Max_Connection (positive)' This is the maximum number of simultaneous connections for the server. This can be used when calling the `AWS.Server.Start'. The default is 5. Note that the total number of threads used by a server is: N =
+ [+ ] Note: [...] means optional value Add 1 only if the session feature is activated. This is due to the session cleaner task. `Receive_Timeout (duration)' Number of seconds to timeout when receiving chunk of data. The default is 30.0 seconds. `Security_Mode (string)' Set the security mode to use for the secure connections. The default mode is "SSLv23". *note AWS.Net.SSL::. `Send_Timeout (duration)' Number of seconds to timeout when sending chunk of data. The default is 40.0 seconds. `Server_Host (string)' The name of the host machine. This can be used if a computer has more than one IP address, it is possible to have two servers at the same port on the same machine, both being binded on different IP addresses. `Server_Name (string)' The name of the server. This can be used when calling `AWS.Server.Start'. The default is "AWS Module". `Server_Port (integer)' The port where server will wait for incoming connections requests. This can be used when calling `AWS.Server.Start'. The default is 8080. `Session_Lifetime (duration)' Number of seconds to keep session information. After this period a session is obsoleted and will be removed at next cleanup. The default is 600.0 seconds. `Session_Cleanup_Interval (duration)' Number of seconds between each run of the session cleanup task. This task will remove all session data that have been obsoleted. The default is 300.0 seconds. `Status_Page (string)' The name of the status page to used. The default is `aws_status.thtml'. `Transient_Cleanup_Interval (positive)' Specify the number of seconds between each run of the cleaner task to remove transient pages. The default value is 180.0 seconds. `Transient_Lifetime' Specify the number of seconds to keep a transient page. After this period the transient page is obsoleted and will be removed during next cleanup. The default value is 300.0 seconds. `Up_Image (string)' The name of the up arrow image to use in the status page. The default is `aws_up.png'. `Upload_Directory (string)' This is to set the directory where upload files must be stored. By default uploaded files are written in the current directory. The default is `./'. `WWW_Root (string)' This option sets the Web Server root directory. All Web resources are referenced from this root directory. The default value is "./". Each option value can be retrieved using the `AWS.Config' unit or set using `AWS.Config.Set'. For example to build a server where the port and the maximum number of connection can be changed via a configuration file (either `aws.ini' or `.ini'): WS : AWS.Server.HTTP; Conf : constant AWS.Config.Object := AWS.Config.Get_Current; Server.Start (WS, Callback => Service'Access, Conf); Session handling ================ `AWS' provides a way to keep session data while users are browsing. There is no need to mess with the Cookies, `AWS' will do that for you. The idea is simple. A session ID will be transparently created and then you'll be able to insert and retrieve session data using a standard Ada API (*Note AWS.Session::.). Session data are key/value pair each of them being strings. How to deal with that ? * First you declare and start an HTTP channel with session enabled: WS : AWS.Server.HTTP; Server.Start (WS, Port => 1234, Callback => Service'Access, Session => True); Here we have built an HTTP channel with a maximum of 3 simultaneous connections using the port 1234. A session ID will be created and sent inside a cookie to the client's browser at the first request. This session ID will be sent back to the server each time the client will ask for a resource to the server. * Next, in the Service callback procedure that you have provided you must retrieve the Session ID. As we have seen, the callback procedure has the following prototype: function Service (Request : in AWS.Status.Data) return AWS.Response.Data; The Session ID is kept in the Request object and can be retrieved using: Session_ID : constant AWS.Session.ID := AWS.Status.Session (Request); * From there it is quite easy to get or set some session data using the provided API. For example: declare C : Integer; begin C := AWS.Session.Get (Session_ID, "counter"); C := C + 1; AWS.Session.Set (Session_ID, "counter", C); end; This example first get the value (as an Integer) for session data whose key is "`counter'", increment this counter and then set it back to the new value. It is also possible to save and restore all session data. It means that the server can be shutdown and launched some time after and all client data are restored as they were at shutdown time. Client will just see nothing. With this feature it is possible to shutdown a server to update its look or because a bug has been fixed for example. It is then possible to restart it keeping the complete Web server context. Authentication ============== `AWS' supports Basic and Digest authentication. The authentication request can be sent at any time from the callback procedure. For this the `AWS.Response.Authenticate' message must be returned. The authentication process is as follow: 1. Send authentication request From the callback routine return an authentication request when needed. function Service (Request : in Status.Data) return Response.Data is URI : constant String := Status.URI (Request); User : constant String := Status.Authorization_Name (Request); begin - URI starting with "/prot/" are protected if URI (URI'First .. URI'First + 5) = "/prot/" and then User = "" then return Response.Authenticate ("AWS", Response.Basic); The first parameter is the Realm, it is just a string that will be displayed (on the authentication dialog box) by the browser to indicate for which resource the authentication is needed. 2. Check authentication When an authentication as been done the callback's request data contain the user and password. Checks the values against an ACL for each protected resources. function Protected_Service (Request : in AWS.Status.Data) return AWS.Response.Data is User : constant String := Status.Authorization_Name (Request); Pwd : constant String := Status.Authorization_Password (Request); begin if User = "xyz" and then Pwd = "azerty" then return ...; Note that the Basic authentication is not secure at all. The password is sent unencoded by the browser to the server. If security is an issue it is better to use the Digest authentication and/or an SSL server. File upload =========== File upload is the way to send a file from the client to the server. To enable file upload on the client side the Web page must contain a FORM with an INPUT tag of type FILE. The FORM must also contain the enctype attribute set to multipart/form-data.
File to process:
On the server side, AWS will retrieve the file and put it into the upload directory. AWS add a prefix to the file to ensure that the filename will be uniq on the server side. The upload directory can be changed using the configuration options. *Note Configuration options::. AWS will also setup the form parameters as usual. In the above example there is two parameters (*Note Form parameters::.) filename This variable contains two values, one with the client side name and one with the server side name. First value : Parameters.Get (P, "filename") The value is the full pathname of the file on the server. (i.e. the upload directory catenated with the prefix and filename). Second value : Parameters.Get (P, "filename", 2) The value is the full pathname of the file on the client side. go The value is "Send File" Communication ============= This API is used to do communication between programs using the HTTP GET protocol. It is a very simple API not to be compared with `GLADE' or `SOAP'. This communication facility is to be used for simple request or when a light communication support is needed. For more complex communications or to achieve inter-operability with other modules it is certainly a good idea to have a look at the `AWS/SOAP' support, *note SOAP::. In a communication there is a Client and a Server. Here is what is to be done on both sides to have programs talking together. Communication - client side --------------------------- On the client side it is quite simple. You just have to send a message using `AWS.Communication.Client.Send_Message'. function Send_Message (Server : in String; Port : in Positive; Name : in String; Parameters : in Parameter_Set := Null_Parameter_Set) return Response.Data; The message is sent to the specified server using the given port. A message is composed of a name which is a string and a set of parameters. There is a parameter set constructor in `AWS.Communication'. This function return a response as for any callback procedure. Communication - server side --------------------------- On the server side things are a bit more complex but not that difficult. You must instantiate the `AWS.Communication.Server' generic package by providing a callback procedure. This callback procedure will must handle all kind of message that a client will send. During instantiation you must also pass a context for the communication server. This context will be passed back to the callback procedure. generic type T (<>) is limited private; type T_Access is access T; with function Callback (Server : in String; Name : in String; Context : in T_Access; Parameters : in Parameter_Set := Null_Parameter_Set) return Response.Data; package AWS.Communication.Server is ... A complete example can be found in the demos directory. Look for `com_1.adb' and `com_2.adb'. Note that this communication API is used by the Hotplug module facility *Note Hotplug module::. Hotplug module ============== An Hotplug module is a module that can by dynamically binded to a running server. It is a Web server and the development process is very similar to what we have seen until now *Note Building an AWS server::. The Hotplug module will register itself to a Web server by sending a message using the communication API. The Hotplug module send to the server a regular expression and an URL. The main server will redirect all URL matching the regular expression to the Hotplug module. Note that the main server will redirect the URL to the first matching regular expression. Hotplug module - creation ------------------------- Here is how to create an Hotplug module: 1. First you create a standard Web server *Note Building an AWS server::. WS : AWS.Server.HTTP (3, 1235, False, Hotplug_CB.Hotplug'Access, False); Here we have a server listening to the port 1235. This server can be used alone if needed as any Server developed with AWS. 2. Then you register the Hotplug module to the main server *Note Communication - client side::. Response := AWS.Communication.Client.Send_Message ("dieppe", 2222, AWS.Server.Hotplug.Register_Message, AWS.Communication.Parameters (".*AWS.*", "http://" & AWS.Utils.Gethostname & ":1235/")); We ask for every `URI' containing the string "AWS" to call the server running on the Hotplug hostname using port `1235'. This message is sent to the communication server running on `dieppe' at port `2222'. 3. When the Hotplug module is stopped, you must unregister it Response := AWS.Communication.Client.Send_Message ("dieppe", 2222, AWS.Server.Hotplug.Unregister_Message, AWS.Communication.Parameters (".*AWS.*")); Here we ask to unregister the Hotplug module. The regular expression served as a key. Hotplug module - server activation ---------------------------------- On the server side you must activate the Hotplug feature: AWS.Server.Hotplug.Activate (WS'Unchecked_Access, 2222); Here WS is a standard Web Server. A complete example can be found in the demos directory. Look for `main.adb' and `hotplug.adb'. Server Push =========== Server Push is a feature that let the Web Server send continuously data to client's Web Browser or client applications. The client does not have to reload at periodic time (which is what is called client pull) to have the data updated, each time the server send a piece of data it gets displayed on the client. To build a push server you need to build an instance of the `AWS.Server.Push' package. This package takes a set of formal parameters. Here are the step-by-step instructions to build a Push Server: 1. The data to be sent First you must create a type that will contains the data to be sent to client's browser except if it is a standard Ada type. See `Client_Output_Type' formal parameter. 2. The data that will be streamed This is the representation of the data that will be sent to client's browser. This will be either a `String' for Web pages or `Stream_Element_Array' for binary data like pictures. See `Stream_Output_Type' formal parameter. 3. The context It is often nice to be able to configure each client with different parameters if needed. This can be achieved with the Context data type that will be passed as parameter of the conversion function described below. See `Client_Environment' formal parameter. 4. Provides a function to convert from the data type to be sent to the data that will be streamed. This is a function that will transform the data described on point 1 above to the form described on point 2 above. See `To_Stream_Output' formal parameter. 5. Build the Push Server To do so you just need to instantiate `AWS.Server.Push' with the above declarations. 6. Registering new clients In the standard `AWS' procedure callback it is possible to register a client if requested. This is done by calling `AWS.Server.Push.Register'. It is possible to unregister a client using `AWS.Server.Push.Unregister'. Each client must be identified with a unique client ID. After registering a new client from the callback procedure you must return the `AWS.Response.Socket_Taken' message. This is very important, it tells the server to not close this socket. 7. Sending the data At this point it is possible to send data to clients. To do so two routines are available. `AWS.Server.Push.Send_To' To send a piece of data to a specific client identified by its client ID. `AWS.Server.Push.Send' To send a piece of data to all clients registered on this server. Very large Internet applications should use this feature carefully. A push server keeps a socket reserved for each registered clients and the number of available sockets per process is limited by the OS. Working with Server sockets =========================== With `AWS' is is possible to take out a socket from the server and give it back later. This feature must be used carefully but it gives a lot of flexibility. As the socket is taken away, the connection line (or slot) is released, `AWS' can then use it to handle other requests. This can be used to better support heavy loaded servers when some requests need a long time to complete. Long time here means longer than most of the other requests which should be mostly interractives for a Web server. Of course in such a case a keep-alive connection is kept open. The usage in such a case is to take out the socket and put it in a waiting line. This releases the connection for the server. When the data to prepare the answer is ready you give back the socket to the server. * Take a socket from the server This first step is done form the callback function. A user instead of replying immediatly decides to take away the socket from the server. The first step is to record the connection socket socket by calling `AWS.Status.Socket'. The second step is to tell the server to not release this socket by returning `AWS.Response.Socket_Taken' from the callback function. At this point the server will continue to serve other clients. Note that this feature is used by the server push implementation *note Server Push::. * Give back the socket to the server Calling `AWS.Sever.Give_Back_Socket' will register the socket for reuse. This socket will be placed into a spool, next time the server will check for incoming requests it will be picked up. Server Log ========== It is possible to have the server activity logged into the file `-Y-M-D.log'. To activate the logging you must call the `AWS.Server.Log.Start', and it is possible to stop logging by calling `AWS.Server.Log.Stop'. Note that `AWS.Server.Log.Start' have a parameter named `Auto_Flush' to control output buffering. This parameter is False by default. If set to True, the log file will be automatically flushed after each data. If the server logging is not buffered, i.e. Auto_Flush is False, the log can still be flushed by calling the `AWS.Server.Log.Flush' routine. *Note AWS.Log::, for more information especially about the way rotating logs can be setup. Using this feature it is possible to have automatic split of the log file each day, each month or at every run. See `AWS.Log' spec. This is very useful to avoid having very big log files. The log format is using the same format than the Apache Web server. - - [] "" For example: 100.99.12.1 - - [22/Nov/2000:11:44:14] "GET /whatever HTTP/1.1" 200 1789 `AWS' also support error log files. If activated every internal error detected by `AWS' will gets logged into this special file. See `AWS.Server.Log.Start_Error' and `AWS.Server.Log.Stop_Error'. For the full set of routines supporting the log facility *note AWS.Server.Log:: . Secure server ============= It is not much difficult to use a secure server (`HTTPS') than a standard one. Here we describe only what is specific to an HTTPS server. Before going further you must check that `AWS' has been configured with `SSL' support. *note Building::. You must also have installed the `OpenSSL' library on your system. If this is done, you can continue reading this section. Initialization -------------- A server is configured as using the HTTPS protocol at the time it is started. The only thing to do is to set the Start's Security parameter to True. This will start a server and activate the `SSL' layer by default. A secure server must use a valid certificate, the default one is `cert.pem'. This certificate has been created by the openssl tool and is valid until year 2008. Yet, this certificate has not been signed. To build a secure server user's can rely on, you must have a valid certificate signed by one of the Certificate Authorities. The certificate to be used must be specified before starting the secure server with `AWS.Server.Set_Security'. AWS.Server.Set_Security (WS, Certificate_Filename => "/xyz/aws.pem"); Creating a test certificate --------------------------- The goal here is not to replace the `OpenSSL' documentation but just to present one way to create a certificate for an `HTTPS' test server. The RSA key $ openssl genrsa -rand -out ca-key.pem Filename must be point to any file, this is used to initialized the random seed. The Certificate $ openssl req -new -x509 -days 730 -key ca-key.pem -out ca-cert.pem Create a single self contained file $ cat ca-key.pem ca-cert.pem > aws.pem A this point you can use `aws.pem' with your server. Protocol -------- There are different security options, either `SSLv2', `SSLv3' or `TLSv1'. `SSLv2' and `SSLv3' are supported by most if not all Web browsers. These are the default protocol used by `AWS'. `TLSv1' is not supported at this point. Unexpected exception handler ============================ When `AWS' detects an internal problem, it calls a specific handler. This handler can be used to log the error, send an alert message or build the answer to be sent back to the client's browser. Here is the spec for this handler: type Unexpected_Exception_Handler is access procedure (E : in Ada.Exceptions.Exception_Occurrence; Log : in out AWS.Log.Object; Error : in Data; Answer : in out Response.Data); The handler can be called in two modes: Non fatal error (Error.Fatal is False) In this case `AWS' will continue working without problem. A bug has been detected but it was not fatal to the thread (slot in `AWS''s terminology) handling. In this case it is possible to send back an application level message to the client's browser. For that you just have to fill the unexpected handler's ANSWER parameter with the right response message. The ERROR parameter receive information about the problem, *note AWS.Exceptions::. Fatal error (Error.Fatal is True) In this case `AWS' will continue working but a thread (slot number ERROR.SLOT in `AWS''s terminology) will be killed. It means that `AWS' will have lost one the simultaneous connection handler. The server will continue working unless it was the last slot handler available. Note that a Fatal error means an `AWS' internal bug and it should be reported if possible. In this mode there is no way to send back an answer to the client's browser and ERROR value must be ignored. The default handler for unexpected exceptions send a message to standard error for fatal errors. For non fatal errors it log a message (if the error log is activated for the server) and send back a message back to the client. The message is either a built-in one or, if present in the server's directory, the content of the `500.tmplt' file. This templates can used the following tags: AUTH_MODE The authorization mode (Either NONE, BASIC or DIGEST). EXCEPTION Exception information with traceback if activated. HTTP_VERSION Either HTTP/1.0 or HTTP/1.1 METHOD The request method (Either GET, HEAD, POST or PUT) PAYLOAD The full `XML' payload for `SOAP' request. PEERNAME The IP address of the client SOAP_ACTION Either True or False. Set to True for a `SOAP' request. URI The complete URI For more information *note AWS.Server:: and *note AWS.Exceptions::. Client side =========== `AWS' is not only a server it also implement the HTTP and HTTPS protocol from the client side. For example with `AWS' it is possible to get a Web page content using the `AWS.Client' API, *Note AWS.Client::. It also support client Keep-Alive connections. It is then possible to request many URI from the same server using the same connection (i.e. the same sockets). `AWS' client API also support proxy, proxy authentication and Web server authentication. Only basic (and not digest) authentication is supported at this time. Let's say that you want to retrieve the `contrib.html' Web page from Pascal Obry's homepage which is . The code to do so is: Data := Client.Get (URL => "http://perso.wanadoo.fr/pascal.obry/contrib.html"); From there you can ask for the result's content type: if Response.Content_Type (Data) = "text/html" then ... end if; Or using the MIME types defined in `AWS.MIME' unit: if Response.Content_Type (Data) = MIME.Text_HTML then ... end if; And display the content if it is some kind of text data: Text_IO.Put_Line (Response.Message_Body (Data)); If the content is some kind of binary data (executable, PNG image, Zip archive...), then it is possible to write the result to a file for example. Look at the `agent' program in the `demos' directory. If the Web page is protected and you must pass the request through an authenticating proxy, the call will becomes: Data := Client.Get (URL => "http://www.mydomain.net/protected/index.html" User => "me", Pwd => "mypwd", Proxy => "192.168.67.1", Proxy_User => "puser", Proxy_Pwd => "ppwd"); The client upload protocol is implemented. Using `AWS.Client.Upload' it is possible to send a file to a server which support the file upload protocol. High level services ******************* Here you will find a description of high level services. These services are ready to use with AWS and can be used together with user's callbacks. Refer to the Ada spec for a complete API and usage description. Directory browser ================= This service will help building a Web directory browser. It has a lot of options to sort directory entries and is based on the templates interface *note AWS.Templates::. This means that you can use the default directory template or provide your own. *note AWS.Services.Directory:: for complete spec and services descriptions. Dispatchers =========== In many AWS applications it is needed to check the URI to give the right answer. This means that part of the application is a big if/elsif procedure. Also, in standard callback it is not possible to have user data. Both of these restrictions are addressed with the Dispatchers facilities. Working with a dispatcher is quite easy: 1. Create a new dispatcher by inheriting from the service you want to build. 2. Register a set of action based on rules (strings, regular expressions depending on the service) Callback dispatcher ------------------- This is a wrapper around the standard callback procedure. It is needed to mix dispatcher based callback and access to procedure callback. Note that it is not in the `AWS.Services.Dispatchers' hierarchy but in `AWS.Dispatchers.Callback' because this is a basic service needed for the server itself. It is referenced here for documentation purpose but an AWS server can be built with using it. *note AWS.Dispatchers.Callback:: for complete spec description. Method dispatcher ----------------- This is a dispatcher based on the request method. A different callback procedure can be registered for the supported request methods: GET, POST, PUT, HEAD. *note AWS.Services.Dispatchers.Method:: for complete spec description. URI dispatcher -------------- This is a dispatcher based on the request resource. A different callback procedure can be registered for specific resources. The resource is described either by its full name (string) or a regular expression. *note AWS.Services.Dispatchers.URI:: for complete spec description. Virtual host dispatcher ----------------------- This is a dispatcher based on the host name. A different callback procedure can be registered for specific host. This is also known as virtual hosting. The same computer can be registered into the DNS with different names. So all names point to the same machine. But in fact you want each name to be seen as a different Web server. This is called virtual hosting. This service will just do that, call different callback procedures or redirect to some machine/port based on the host name in the client's request. *note AWS.Services.Dispatchers.Virtual_Host:: for complete spec description. Transient pages dispatcher -------------------------- This is a dispatcher that calls a user's callback and if the resource requested is not found (i.e. the user's callback returns status code 404) it checks if this resource is known as a transient page. *note Transient Pages::. Timer dispatcher ---------------- A timer dispatcher can be used to call different callback routines depending on the current date and time. Such dispatcher is composed of a set of `Period' activated. When the current date and time is inside a `Period' the corresponding callback is called. A `Period' can eventually be repeated. Here are the different kind of `Period' supported by `AWS': Once A unique period in time. The boundaries are fully described using a year, month, day, hour, minute and second. Yearly A period that repeats each year. The boundaries are described using a month, day, hour, minute and second. Monthly A period that repeats each month. The boundaries are described using a day, hour, minute and second. Weekly A period that repeats each week. The boundaries are described using a day name, hour, minute and second. Daily A period that repeats each day. The boundaries are described using an hour, minute and second. Hourly A period that repeats each hour. The boundaries are described using a minute and second. Minutely A period that repeats each minute. The boundaries are described using a second. `SOAP' dispatcher ----------------- `AWS' provides also a `SOAP' specific dispatcher. This is a way to automatically route HTTP requests or `SOAP' requests to different callback routines. *note SOAP helpers:: for more information. *note SOAP.Dispatchers.Callback:: for complete spec description. Static Page server ================== This service is a ready to use static page server callback. Using it is possible to build a simple static page server, as simple as: with AWS.Server; with AWS.Services.Page_Server; procedure WPS is WS : AWS.Server.HTTP; begin AWS.Server.Start (WS, "Simple Page Server demo", Port => 8080, Callback => AWS.Services.Page_Server.Callback'Access, Max_Connection => 5); AWS.Server.Wait (AWS.Server.Q_Key_Pressed); AWS.Server.Shutdown (WS); end WPS; Build this program and launch it, it will server HTML pages and images in the current directory. It is possible to activate the directory browsing facility of this simple page server. This is not activated by default. This feature is based on the directory browsing service *note Directory browser::. Note that this service uses two template files: aws_directory.thtml The template page used for directory browsing. See *note AWS.Services.Directory:: for a full description of this template usage. 404.thtml The Web page returned if the requested page is not found. This is a template with a single tag variable named PAGE. It will be replaced by the ressource which was not found. Note that on Microsoft IE this page will be displayed only if the total page size is bigger than 512 bytes or it includes at least one image. *note AWS.Services.Page_Server:: for a complete spec description. Transient Pages =============== A transient page is a resource that has a certain life time on the server. After this time the resource will be released and will not be accessible anymore. Sometimes you want to reference, in a Web page, a resource that is built in memory by the server. This resource can be requested by the client (by clicking on the corresponding link) or not, in both cases the page must be released after a certain amount of time to free the associated memory. This is exactly what the transient pages high level service do automatically. Each transient page must be registered into the service, a specific routine named `Get_URI' can be used to create a unique `URI' on this server. *note AWS.Services.Transient_Pages::. A transient pages dispatcher can be used to build a transient pages aware server. *note Transient pages dispatcher::. Split pages =========== It not not very convenient to send back a Web page with a large table. In such a case it is better to split the table in chunks (20 lines or so) and to send only the first page. This page reference the next pages and can also contains an index of the pages. The `AWS''s split page feature can automatically do that for you. Given template `Translate_Table' and the max line per page it returns the first page and create a set of transient pages for all other pages. A set of template tags are used to reference the previous and next page and also to build the page index. *note AWS.Services.Split_Pages::. Using `SOAP' ************ `SOAP' can be used to implements Web Services. The `SOAP' implementation uses `AWS HTTP' as the transport layer. `SOAP' is platforms and languages independent, to ensure a good inter-operability, `AWS/SOAP' implementations have been validated through , the version number listed on this server corresponds to the AWS version string (`AWS.Version') catenated with the `SOAP' version string (`SOAP.Version'). This `SOAP' implementation is certainly one with the higher level of abstraction. No need to mess with a serializer, to know what is a payload or be an `XML' expert. All the low level stuffs are completely hidden as the `SOAP' type system has been binded as much as possible to the Ada type system. The `SOAP' type system has been relaxed to be compatible with `WSDL' based `SOAP' implementation. In these implementations, types are generally (as in the Microsoft implementation) not part of the payload and should be taken from the `WSDL' (Web Services Description Language). `AWS/SOAP' is not `WSDL' compliant at this stage, all such types are binded into the Ada type system as strings. It is up to the programer to convert such strings to the desired type. `SOAP' Client ============= The `SOAP' client interface is quite simple. Here are the step-by-step instructions to call a `SOAP' Web Service: 1. Build the `SOAP' parameters As for the `SOAP' servers, the `SOAP' parameters are built using a `SOAP.Parameters.List' object. Params : constant Parameters.List := +I (10, "v1") & I (32, "v2"); 2. Build the `SOAP' Payload The Payload object is the procedure name and the associated parameters. declare Payload : Message.Payload.Object; begin Payload := Message.Payload.Build ("Add", Params); 3. Call the `SOAP' Web Service Here we send the above Payload to the Web Server which handles the Web Service. Let's say that this server is named `myserver', it is listening on port `8082' and the `SOAPAction' is `soapdemo'. Resp : constant Message.Response.Object'Class := SOAP.Client.Call ("http://myserver:8082/soapdemo", Payload); 4. Retrieve the result Let's say that the answer is sent back into the parameter named "myres", to get it: My_Res : constant Integer := SOAP.Parameters.Get (Params, "myres"); In the above example we have called a Web Service whose spec could be described in Ada as follow: function Add (V1, V2 : in Integer) return Integer; - Add V1 and V2 and returns the result. In SOAP the result is named "myres" `SOAP' Server ============= A `SOAP' server implementation must provides a callback procedure as for standard Web server *note Callback procedure::. This callback must checks for the `SOAP' Action URI to handle both standard Web requests and `SOAP' ones. The `SOAPAction' is sent with the HTTP headers and can be retrieved using `AWS.Status.SOAPAction'. Step by step instructions ------------------------- Here are the step-by-step instructions to be followed in the `SOAP' callback procedure: 1. Retrieve the `SOAP' Payload The `SOAP' Payload is the `XML' message, it contains the procedure name to be called and the associated parameters. function SOAP_CB (Request : in AWS.Status.Data) return AWS.Response.Data is use SOAP.Types; use SOAP.Parameters; Payload : constant SOAP.Message.Payload.Object := SOAP.Message.XML.Load_Payload (AWS.Status.Payload (Request)); `AWS.Status.Payload' returns the `XML' Payload as sent by the `SOAP' Client. This `XML' Payload is then parsed using `SOAP.Message.XML.Load_Payload' which returns a `SOAP.Message.Payload.Object' object. 2. Retrieve the `SOAP' Parameters The `SOAP' procedure's parameters. Params : constant SOAP.Parameters.List := SOAP.Message.Parameters (Payload); `SOAP.Parameters.List' is a structure which holds the `SOAP' parameters. Each parameter can be retrieved using a `SOAP.Parameters' API, *note SOAP.Parameters::. For example to get the parameter named `myStruc' which is a `SOAP' struct: My_Struct : constant SOAP_Record := SOAP.Parameters.Get (Params, "myStruct"); Another example, to get the parameter named `myInt' which is a `SOAP' integer: My_Int : constant Integer := SOAP.Parameters.Get (Params, "myInt"); 3. Implements the Web Service This is the real job, as for any procedure you can do whatever is needed to compute the result. 4. Build the `SOAP' answer This is the procedure answer. A `SOAP' answer is built from the `SOAP' Payload and by setting the returned parameters. declare Resp : SOAP.Message.Response.Object; Resp_Params : SOAP.Parameters.List; begin Resp := SOAP.Message.Response.From (Payload); Resp_Params := +I (My_Int * 2, "answer"); SOAP.Message.Set_Parameters (Resp, Resp_Params); This build a response which is a single integer value named `answer' with the value `My_Int * 2'. 5. Returns the answer back to the client This last step will encode the response object in `XML' and will returns it as the body of an `HTTP' message. return SOAP.Message.Response.Build (Resp); `SOAP' helpers -------------- There is two ways to help building the `SOAP' callbacks. `AWS' provides a `SOAP' specific callback, the spec is : function SOAP_Callback (SOAPAction : in String; Payload : in Message.Payload.Object; Request : in AWS.Status.Data) return AWS.Response.Data; With both solutions exposed below, `AWS' retrieve the `SOAPAction' and the Payload from the `SOAP' request. This is transparent to the user. 1. Using Utils.SOAP_Wrapper It is possible to dispatch to such callback by using the `SOAP.Utils.SOAP_Wrapper' generic routine. generic with function SOAP_CB (SOAPAction : in String; Payload : in Message.Payload.Object; Request : in AWS.Status.Data) return AWS.Response.Data; function SOAP_Wrapper (Request : in AWS.Status.Data) return AWS.Response.Data; - From a standard HTTP callback call the SOAP callback passed as generic - formal procedure. Raise Constraint_Error if Request is not a SOAP - request. For example, from the standard HTTP callback `CB' we want to call `SOAP_CB' for all `SOAP' requests: function SOAP_CB (SOAPAction : in String; Payload : in Message.Payload.Object; Request : in AWS.Status.Data) return AWS.Response.Data is begin - Code here end SOAP_CB; procedure SOAP_Wrapper is new SOAP.Utils.SOAP_Wrapper (SOAP_CB); function CB (Request : in AWS.Status.Data) return AWS.Response.Data is SOAPAction : constant String := Status.SOAPAction (Request); begin if SOAPAction /= "" then SOAP_Wrapper (Request); else ... 2. Using a SOAP Dispatcher `AWS' provides also a `SOAP' specific dispatcher. This dispatcher will automatically calls a standard `HTTP' or `SOAP' callback depending on the request. If `SOAPAction' is specified (i.e. it is a `SOAP' request), the dispatcher will call the `SOAP' callback otherwise it will call the standard `HTTP' callback. This is by far the easiest integration procedure. Using dispatcher the above code will be written: function SOAP_CB (SOAPAction : in String; Payload : in Message.Payload.Object; Request : in AWS.Status.Data) return AWS.Response.Data is begin - Code here end SOAP_CB; function CB (Request : in AWS.Status.Data) return AWS.Response.Data is SOAPAction : constant String := Status.SOAPAction (Request); begin - Code here end CB; - In the main procedure begin AWS.Server.Start (WS, Dispatcher => SOAP.Dispatchers.Callback.Create (CB'Access, SOAP_CB'Access), Config => AWS.Config.Default_Config); The dispacther is created using `SOAP.Dispatchers.Callback.Create'. This routine takes two parameters, one is the standard HTTP callback procedure and the other is the `SOAP' callback procedure. Using `WSDL' ************ `WSDL' (Web Service Definition Language) is an `XML' based document which described a set of Web Services either based on `SOAP' or `XML/RPC'. By using a `WSDL' document it is possible to describe, in a formal way, the interface to any Web Services. The `WSDL' document contains the end-point (URL to the server offering the service), the `SOAPAction' (needed to call the right routine), the procedure names and a description of the input and output parameters. `AWS' provides two tools to work with `WSDL' documents: `ada2wsdl' which creates a `WSDL' document from an Ada package spec. `wsdl2aws' which create the interfaces to use a Web Service or to implement Web Services. With this tool the `SOAP' interface is completely abstracted out, users will deal only with `Ada' API. All the `SOAP' marshaling will be created automatically. Creating `WSDL' documents ========================= Note that this tool is based on `ASIS'. Using ada2wsdl -------------- `ada2wsdl' can be used on any Ada spec file to generated a `WSDL' document. The Ada spec is parsed using `ASIS'. The simplest way to use it is: $ ada2wsdl simple.ads Given the following Ada spec file: package Simple is function Plus (Value : in Natural) return Natural; end Simple; It will generate the following `WSDL' document: In bold are marked the important parts from a spec point of view. The first item is the name of the `WSDL' document (the name of the Ada spec package). On the `portType' section we have the description of the Ada Plus function. Something important to note is that in Ada a function does not have a named return parameter, `ada2wsdl' use Result for the response. Both the input and output parameter are mapped to `SOAP' `xsd:int' type. Note that the `SOAP' address generated by default (http://.../) must be edited manually or specified using `ada2wsdl''s -a option. This is of course a very simple example. `ada2wsdl' does support lot more complex specs and will map Ada records, arrays, enumerations, derived types to a corresponding `XML' schema definition. See section below for a description of the mapping. Ada mapping to WSDL ------------------- `ada2wsdl' parse Ada records, arrays, derived types, enumerations, procedures and functions and generate the corresponding `WSDL' document. In this section we describe the mapping between Ada and `WSDL'. Integer Mapped to xsd:int. Float Mapped to xsd:float. Note that `Float' type should not be used as xsd:float is really an Ada `Long_Float'. `ada2wsdl' will issue a warning if such type is used. Note also that full interoperability is not supported for type `Float'. Long_Float Mapped to xsd:float Long_Long_Float Mapped to xsd:double Boolean Mapped to xsd:boolean String Mapped to xsd:string Unbounded_String Mapped to xsd:string, note that Unbounded_String should be used only inside a record for full interoperability. This is a current limitation. Character Mapped to a Character schema definition. SOAP.Utils.SOAP_Base64 Mapped to xsd:base64Binary. `SOAP.Utils.SOAP_Base64' is a subtype of string which is is recognized by `ada2wsdl' to generate the proper SOAP type. Enumerations Mapped to an enumeration schema definition. For example: type Color is (Red, Green, Blue); is defined as: Records Mapped to an struct schema definition. For example: type Rec is record A : Integer; B : Long_Float; C : Long_Long_Float; D : Character; E : Unbounded_String; F : Boolean; end record; is defined as: Arrays Mapped to an array schema definition. For example: type Set_Of_Rec is array (Positive range <>) of Rec; is defined as: Array inside a record This part is a bit delicate. A record field must be constrained but a `SOAP' arrays is most of the time not constrained at all. To support this `AWS' use a safe access array component. Such a type is built using a generic runtime support package named `SOAP.Utils.Safe_Pointers'. This package implements a reference counter for the array access and will release automatically the memory when no more reference exists for a given object. For example, let's say that we have an array of integer that we want to put inside a record: type Set_Of_Int is array (Positive range <>) of Integer; The first step is to create the safe array access support: type Set_Of_Int_Access is access Set_Of_Int; package Set_Of_Int_Safe_Pointer is new SOAP.Utils.Safe_Pointers (Set_Of_Int, Set_Of_Int_Access); Note that the name `Set_Of_Int_Safe_Pointer' (_Safe_Pointer) is mandatory (and checked by `ada2wsdl') to achieve interoperability with `wsdl2aws'. *note Working with WSDL documents::. From there the safe array access can be placed into the record: type Complex_Rec is record SI : Set_Of_Int_Safe_Pointer.Safe_Pointer; end record; To create a Safe_Pointer given a `Set_Of_Int' one must use `Set_Of_Int_Safe_Pointer.To_Safe_Pointer' routine. Accessing individual items is done with `SI.Item (K)'. These Ada definitions are full recognized by `ada2wsdl' and will generate standard array and record `WSDL' definitions as seen above. ada2wsdl -------- Usage: ada2wsdl [options] ada_spec `ada2wsdl' options are: -a url Specify the `URL' for the Web Server address. Web Services will be available at this address. A port can be specified on the `URL', `http://server[:port]'. The default value is `http://.../'. -f Force creation of the `WSDL' file. Overwrite exiting file with the same name. -I path Add path option for the `ASIS' compilation step. This option can appear any number of time on the command line. -noenum Do not generate `WSDL' representation for Ada enumerations, map them to standard string. *note Ada mapping to WSDL::. -o file Generate the `WSDL' document into file. -q Quiet mode (no output) -s name Specify the Web Service name for the `WSDL' document, by default the spec package's name is used. -v Verbose mode, display the parsed spec. `ada2wsdl' limitations ---------------------- * Do not handle constraint arrays into a records. * Unbounded_String are supported with full interoperability only inside a record. * Only unconstraint arrays are supported * Arrays with multiple dimentions not supported Working with `WSDL' documents ============================= Client side (stub) ------------------ This section describe how to use a Web Service. Let's say that we want to use the Barnes & Noble Price Quote service. The WSDL document for this service can be found at . In summary this document says that there is a service named `getPrice' taking as input a string representing the ISBN number and returning the price as floating point. The first step is to generate the client interface (stub): $ wsdl2aws -noskel http://www.xmethods.net/sd/2001/BNQuoteService.wsdl This will create many files, the interesting one at this point is `bnquoteservice-client.ads', inside we have: function getPrice (isbn : in String) return Long_Float; -- Raises SOAP.SOAP_Error if the procedure fails Let's call this service to find out the price for The Sword of Shannara Trilogy book. with Ada.Text_IO; with BNQuoteService.Client; procedure Price is use Ada; ISBN : constant String := "0345453751"; -- The Sword of Shannara Trilogy ISBN package LFIO is new Text_IO.Float_IO (Long_Float); begin Text_IO.Put_Line ("B&N Price for The Sword of Shannara Trilogy"); LFIO.Put (BNQuoteService.Client.getPrice (ISBN), Aft => 2, Exp => 0); end Price; That's all is needed to use this Web Service. This program is fully functional, It is possible to build it and to run it to get the answer. Server side (skeleton) ---------------------- Building a Web Service can also be done from a `WSDL' document. Let's say that you are Barnes & Noble and that you want to build Web Service `getPrice' as described in the previous section. You have created the `WSDL' document to specify the service spec. From there you can create the skeleton: $ wsdl2aws -nostub http://www.xmethods.net/sd/2001/BNQuoteService.wsdl This will create many files, the interesting one here is `bnquoteservice-server.ads', inside we have: Port : constant := 80; generic with function getPrice (isbn : in String) return Long_Float; function getPrice_CB (SOAPAction : in String; Payload : in SOAP.Message.Payload.Object; Request : in AWS.Status.Data) return AWS.Response.Data; This is a `SOAP AWS''s callback routine that can be instantiated with the right routine to retrieve the price of a book given its ISBN number. A possible implementation of such routine could be: function getPrice (isbn : in String) return Long_Float is begin if isbn = "0987654321" then return 45.0; elsif ... end getPrice; function SOAP_getPrice is new BNQuoteService.Server.getPrice_CB (getPrice); `SOAP_getPrice' is a `SOAP AWS''s callback routine (i.e. it is not a standard callback). To use it there is different solutions: Using SOAP.Utils.SOAP_Wrapper This generic function can be used to translate a standard callback based on `AWS.Status.Data' into a `SOAP' callback routine. function getPrice_Wrapper is new SOAP.Utils.SOAP_Wrapper (SOAP_getPrice); The routine `getPrice_Wrapper' can be used as any other AWS's callback routines. Note that inside this wrapper the `XML' payload is parsed to check the routine name and to retrieve the `SOAP' parameters. To call this routine the payload needs to be parsed (we need to know which routine has be invoked). In this case we have parsed the `XML' payload twice, this is not efficient. Building the wrapper yourself This solution is more efficient if there is many `SOAP' procedures as the payload is parsed only once. function CB (Request : in Status.Data) return Response.Data is SOAPAction : constant String := Status.SOAPAction (Request); Payload : constant SOAP.Message.Payload.Object := SOAP.Message.XML.Load_Payload (AWS.Status.Payload (Request)); Proc : constant String := SOAP.Message.Payload.Procedure_Name (Payload); begin if SOAPAction = "..." then if Proc = "getPrice" then return SOAP_getPrice (SOAPAction, Payload, Request); elsif ... ... end if; else ... end if; Note that the port to be used by the AWS server is described into the server spec. wsdl2aws -------- Usage: wsdl2aws [options] It is possible to pass a `WSDL' file or direct `wsdl2aws' to a `WSDL' document on the Web by passing it's `URL'. `wsdl2aws' options are: -q Quiet mode (no output) -a Generate using Ada style names. For example `getPrice' will be converted to `Get_Price'. This formatting is done for packages, routines and formal parameters. -f Force creation of the file. Overwrite any exiting files with the same name. -s Skip non supported `SOAP' routines. If `-s' is not used, `wsdl2aws' will exit with an error when a problem is found while parsing the `WSDL' document. This option is useful to skip routines using non supported types and still be able to compile the generated files. -o name Specify the name of the local `WSDL' document. This option can be used only when using a Web `WSDL' document (i.e. passing an URL to `wsdl2aws'). -doc Handle document style binding as RPC ones. This is sometimes needed because some `WSDL' document specify a document style binding even though it is really an RPC one. -v Verbose mode, display the parsed spec. -v -v Verbose mode, display the parsed spec and lot of information while parsing the `WSDL' document tree. -wsdl Add `WSDL' document as comment into the generated root unit. -cvs Add CVS Îd tag in every generated file. -nostub Do not generated stubs, only skeletons are generated. -noskel Do not generated skeletons, only stubs are generated. -cb Generate a `SOAP' dispatcher callback routine for the server. This dispatcher routine contains the code to handle all the operations as described in the `WSDL' document. You need also to specify the `-types' option, see below. -types spec Specify the name of the spec containing the Ada implementation of the `SOAP' routines. This is used for example by the `-cb' option above to instantiate all the server side `SOAP' callbacks used by the main `SOAP' dispatcher routine. -main filename Specify the name of the server's procedure main to generate. If file `.amt' (Ada Main Template) is present, it uses this template file to generate the main procedure. The template can reference the following variable tags: SOAP_SERVICE The name of the service as described into the `WSDL' document. This tag can be used to include the right units with @_SOAP_SERVICE_@.Client; with @_SOAP_SERVICE_@.CB; SOAP_VERSION The AWS's SOAP version. AWS_VERSION The AWS's version. UNIT_NAME The name of the generated unit. This is the name of the procedure that will be created. procedure @_UNIT_NAME_@ is begin ... -proxy name|IP Use this proxy to access the `WSDL' document and generate code to access to these Web Services via this proxy. The proxy can be specified by its DNS name or IP address. -pu name User name for the proxy if proxy authentication required. -pp password User password for the proxy if proxy authentication required. wsdl2aws behind the scene ------------------------- The `wsdl2aws' tool read a `WSDL' document and creates a root package and a set of child packages as described below: This is the main package, it contains eventually the full `WSDL' in comment and the description of the services as read from the `WSDL' document. .Types This package contains the definitions of the types which are not `SOAP' base types. We find here the definitions of the `SOAP' structs and arrays with routines to convert them between the Ada and `SOAP' type model. A subtype definition is also created for every routine's returned type. .Client All spec to call Web Services. .Server All spec to build Web Services. These specs are all generic and must be instantiated with the right routine to create the web services. .CB The `SOAP' dispatcher callback routine. wsdl2aws limitations -------------------- It is hard to know all current limitations as the `WSDL' and `SOAP' world is quite complex. We list there all known limitations: * Many `SOAP' base types are not supported : byte, unsignedByte, short, unsignedShort, unsignedInt, long, unsignedLong, double, date, time, xsd:hexBinary, decimal. All these are easy to add (except decimal), it is just not supported with the current version. * Multi-dimension arrays are not supported. * anyType is not supported Using ada2wsdl and wsdl2aws together ==================================== Using both tools together is an effective way to build rapidely a `SOAP' server. It can be said that doing so is quite trivial in fact. Let's take the following spec: package Graphics is type Point is record X, Y : Long_Float; end record; function Distance (P1, P2 : in Point) return Long_Float; -- Returns the distance between points P1 and P2 end Graphics; We do not show the body here but we suppose it is implemented. To build a server for this service it is as easy as: $ ada2wsdl -a http://localhost:8787 -o graphics.wsdl graphics.ads The server will be available on localhost at port 8787. $ wsdl2aws -cb -main server -types graphics graphics.wsdl $ gnatmake server -largs ... Options `-cb' is to create the `SOAP' dispatcher callback routine, `-main server' to generate the main server procedure in `server.adb', `-types graphics' to use `graphics.ads' to get references from user's spec (reference to `Graphics.Point' for example). Working with mails ****************** Sending e-mail ============== `AWS' provides a complete API to send e-mail using `SMTP' protocol. You need to have access to an SMTP server to use this feature. The API covers sending simple mail with text message and/or with `MIME' attachments (base64 encoded). Here are the steps to send a simple e-mail: * Initialize the SMTP server SMTP_Server : SMTP.Receiver := SMTP.Client.Initialize ("smtp.hostname"); Here `AWS' uses the default SMTP port to create an SMTP mail server but it is possible to specify a different one. The hostname specified must be a valid SMTP server. * Send the e-mail To send an e-mail there is many different API. Let's send a simple text mail. Status : SMTP.Status; SMTP.Client.Send (SMTP_Server, From => SMTP.E_Mail ("Pascal Obry", "p.obry@wanadoo.fr"), To => SMTP.E_Mail ("John Doe", "john.doe@here.com"), Subject => "About AWS SMTP protocol", Message => "AWS can now send mails", Status => Status); Here Status will contain the SMTP returned status. * Check that everything is ok Using above status data it is possible to check that the message was sent or not by the server. The status contain a code and an error message, both of them can be retrieved using specific routines, *Note AWS.SMTP::. It is also possible to check that the call was successful with `SMTP.Is_Ok' routine. if not SMTP.Is_Ok (Status) then Put_Line ("Can't send message: " & SMTP.Status_Message (Status)); end if; In the above example, the message content was given as a string but it is possible to specify a disk file. `AWS' can also send MIME messages either from disk files or with in memory base64 encoded binary data. The API provides also a way to send messages to multiple recipients at the same time. These features are not described here, complete documentation can be found on the spec *note AWS.SMTP:: and *note AWS.SMTP.Client::. Retrieving e-mail ================= `AWS' provides an API to retrieve e-mails from a `POP' mailbox. `POP' stands for Post Office Protocol and is the main protocol used by Internet Service Providers around the world. `IMAP' is another well known protocol in this area but it is not supported by `AWS'. We describes here the `POP' API. For a complete description see *note AWS.POP::. * Opening the mailbox The first step is to authenticate using a user name and password. `AWS' supports two methods one called `Clear_Text' which is the most used and another one `APOP' which is more secure but almost not supported by `ISP' for the moment (and will probably never be supported as a more secure protocol named `SPA' -Secure Password Authentication- could be used instead). Mailbox : POP.Mailbox := POP.Initialize ("pop.hostname", "john.does", "mysuperpwd"); The default Authentication method is `Clear_Text'. * Getting mailbox information When the connection is opened it is possible to get information about the mailbox like the number of messages or the total number of bytes in the mailbox. N : constant Natural := POP.Message_Count (Mailbox); Bytes : constant Natural := POP.Size (Mailbox); * Retreiving individual e-mail Each message is numbered starting from 1. A function named `Get' will return a message given its mailbox's number. Message : constant POP.Message := POP.Get (Mailbox, 2, Remove => True); Remove can be set to `False' for the message to stay on the mailbox. The default value is `False'. * Iterating through the mailbox content Another way to retreive message is by using an iterator. procedure Print_Subject (Message : in POP.Message Index : in Positive; Quit : in out Boolean) is begin Text_IO.Put_Line (POP.Subject (Message)); end Print_Message; procedure Print_All_Subjects is new POP.For_Every_Message (Print_Subject); ... Print_All_Subjects (Mailbox, Remove => True); It exists a set of routines on a `POP.Message' object to get the subject the content, the date or any headers. It is also possible to work with attachments. See point below. * Working with attachments A message can have a set of `MIME' attachments. The number of attachments can be retrieved using `Attachment_Count'. Message : constant POP.Message := ...; A_Count : constant Natural := POP.Attachment_Count (Message); As for messages it is possible to get a single attachment using its index in the message or by using an iterator. First_Attachment : constant POP.Attachment := POP.Get (Message, 1); procedure Write_Attachment (Attachment : in POP.Attachment Index : in Positive; Quit : in out Boolean) is begin POP.Write (Attachment, Directory => "."); end Print_Message; procedure Write_All_Attachments is new POP.For_Every_Attachment (Write_Attachment); ... Write_All_Attachments (Message); It is also possible to retrieve the attachment's filename, the content as a memory stream. *note AWS.POP::. * Closing the connection POP.Close (POP_Server); LDAP **** `AWS' provides a complete API to retrieve information from LDAP servers. Note that there is no support for updating, modifying or deleting information only to read information from the server. The `AWS/LDAP' implementation is based on `OpenLDAP'. To build an LDAP application you need to link with the `libldap.a' library. This library is built by `AWS' on Windows based system and will use the `wldap32.dll' as provided with Windows NT/2000/XP. On UNIX based systems, you must install properly the `OpenLDAP' package. The steps required to read information from an LDAP server are: Initialize the LDAP directory declare Directory : LDAP.Client.Directory; begin Directory := LDAP.Client.Init (Host); Host is the hostname where the LDAP directory is running. It is possible to specify the port if the LDAP server does not use the default one. Bind to the LDAP server This step is the way to pass a login/password if the LDAP server required an authentication. If not, the login/password must be empty strings. LDAP.Client.Bind (Directory, "", ""); Do the search For the search you must specify the base name, a filter, the scope and a set of attributes to retrieve. Response_Set := LDAP.Client.Search (Directory, Base_DN, Filter, LDAP.Client.LDAP_Scope_Subtree, LDAP.Client.Attributes ("cn", "sn", "telephonenumber")); Attributes The set of attributes to retrieve from the directory. Filter A set of values for some attributes. A filter is = where value can contain '*' at the end. For example "(cn=DUPON*)" will look for all entries where the common name is starting by the string "DUPON". Scope Define how far in the hierarchical directory the search will operate. It is either one level, all subtrees or on the base of the tree. For more information *note AWS.LDAP.Client::. Iterate through the response set For this there is two iterators. `First_Entry'/`Next_Entry' or the generic high level iterator `For_Every_Entry'. declare Message : LDAP.Client.LDAP_Message; begin Message := LDAP.Client.First_Entry (Directory, Response_Set); while Message /= LDAP.Client.Null_LDAP_Message loop Do_Job (Message); Message := LDAP.Client.Next_Entry (Directory, Message); end loop; end; Read attributes for each entry Each entry has an associated set of attributes. To retrieve attributes values there is two iterators. `First_Attribute' / `Next_Attribute' or the generic high level iterator `For_Every_Attribute'. declare BER : aliased LDAP.Client.BER_Element; Attr : constant String := LDAP.Client.First_Attribute (Directory, Message, BER'Unchecked_Access); begin Do_Job (Attr); loop declare Attr : constant String := LDAP.Client.Next_Attribute (Directory, Message, BER); begin exit when Attr = ""; Do_Job (Attr); end; end loop; end; Cleanup At the end of the processing it is important to release memory associated with LDAP objects. LDAP.Client.Free (Message); LDAP.Client.Unbind (Directory); *note AWS.LDAP.Client:: for all high level supported API and documentation. Note that for complete information about `AWS/LDAP' you you should read an LDAP API description. `AWS/LDAP' is only a binding and follow the LDAP API closely. Jabber ****** `AWS' support part of the Jabber protocol. At this stage only two kind of messages are supported: 1. Presence To check the presence status of a specific JID (Jabber ID) 2. Message To send messages to a specific JID (Jabber ID) Note that if you want an application to check the presence or send message to users it is recommended to create a specific Jabber ID on the server for this application and ask users to accept this specific user to check their presence status. Jabber presence =============== To check for the presence of another JID you must first have the right to do so. The jabber server won't let you see presence of another JID unless the JID have permitted you to see its presence. * First declare the server and status objects Server : AWS.Jabber.Server; Status : AWS.Jabber.Presence_Status; * Connect to the server, you must have an account created and must know the login and password AWS.Jabber.Connect (Server, "jabber.domain.org", "joe", "mysuperpwd"); * Then, to check the presence of user "john" AWS.Jabber.Check_Presence (Server, "john@jabber.domain.org", Status); * Then, you just have to close the server AWS.Jabber.Close (Server); Jabber message ============== To send a message to a specific JID, you must connect to the server as above and close the server when you don't need to communicate with it anymore. The only different part is to send the message, here is an example: Send_Message (Server, JID => "john@jabber.domain.org", Subject => "Hello there!", Content => "Are you using AWS ?"); It is as simple as that ! Resources ********* `AWS' support embedded resources. It means that it is possible to build a fully self dependent executable. This is useful when distributing a server. The server program contains the code but also the images (PNG, JPEG, GIF), the templates, the HTML pages... more generally any file the Web Server must serve to clients. Building resources ================== To embbed the files into the executable you must build a resource tree. This task is greatly simplified using `AWSRes' tool. For example let's say that you want to build a simple server with a single page containing some text and one PNG image. The text is handled directly in the callback procedure and contain a reference to the image `logo.png'. To build the resource tree: $ awsres logo.png This will create a set of packages whose root is the unit `res' by default. The resource tree is created. *note awsres tool:: for the complete AWS's usage description. `awsres' can also compress the resource files. This can be done by using `awsres''s `-z' option. Compressed resources are handled transparently. If the Web client supports compression the resource is sent as-is otherwise a decompression stream will be created for the resource to be decompressed on-the-fly while sending it. Using resources =============== This is really the simplest step. The resource tree must be linked with your executable, to do so you just have to "with" the resource tree root into one of your program unit. This will ensure that the resource tree will be compiled and linked into the executable. `AWS' and `Templates_Parser know' about resource files and will pick them up if available. Note that this is transparent to users. It is possible to build the very same server based on standard files or resources files. The only change in the code is to "with" or not the resource tree. Note that `AWS' supports only a single resource tree. If more than one resource tree is included into a program only one will be seen. Stream resources ================ Users can build a response directly from a stream. In this case the callback answer is built using `AWS.Response.Stream'. It creates a resource object whose operations have been inherited from `AWS.Resource.Stream.Stream_Type' and redefined by the user. So the `Read' operation can dynamically create the result stream data, the `End_Of_File' operation must returns `True' when the stream data is out and so on. This feature is useful to let users completely create and control dynamically `AWS''s response content. *note AWS.Resources.Streams::. awsres tool =========== `AWSRes' is a tool to build resource files. It creates a root package named `res' by default and a child package for each resource file. Usage: awsres [-hrquz] file1 [-uz] [file2...] `-h' Display help message. `-q' Quiet mode. `-r name' Set the root unit name. Default is `res'. `-u' Add following files as uncompressed resources. `-z' Add following files as compressed resources. Status page *********** The status page gives information about the `AWS' internal status. For example it returns the server socket ID, the number of simultaneous connection, the number of time a connection has been used... To display the information `AWS' use a template file. The template file (default is `aws_status.thtml') is an HTML file with some specific tags recognized by the parser. For more information about how the template parser works, please look for the template parser documentation distributed with `AWS' or on the Web at in the Ada section. Here are the tag variables recognized by `AWS' status page: ACCEPT_QUEUE_SIZE *note Configuration options::. ABORTABLE_V (vector tag) A list of boolean. One for each connection. True means that this connection can be aborted if none is available. This is to be inserted in a template table. ACTIVITY_COUNTER_V (vector tag) A list of natural. One for each connection. This is the number of request the connection has answered. This counter is reset each time the connection is closed. In other word this is the number of request a keep-alive connection has processed. ACTIVITY_TIME_STAMP_V (vector tag) A list of date. One for each connection. This is the time of the latest request answered. CLEANER_WAIT_FOR_CLIENT_TIMEOUT *note Configuration options::. CLEANER_CLIENT_HEADER_TIMEOUT *note Configuration options::. CLEANER_CLIENT_DATA_TIMEOUT *note Configuration options::. CLEANER_SERVER_RESPONSE_TIMEOUT *note Configuration options::. FORCE_WAIT_FOR_CLIENT_TIMEOUT *note Configuration options::. FORCE_CLIENT_HEADER_TIMEOUT *note Configuration options::. FORCE_CLIENT_DATA_TIMEOUT *note Configuration options::. FORCE_SERVER_RESPONSE_TIMEOUT *note Configuration options::. KEYS_M (matrix tag) A list of set of keys (for each key correspond a value in the tag VALUES_L, see below). Each key in the vector tag start with an HTML "" tag. This is to be able to display the key/value in column. LOGO A string to be placed in an img HTML tag. This is the name of the AWS logo image. LOG (boolean tag) This is set to true if logging is active. LOG_FILE The log file full pathname. LOG_MODE The rotating log mode, this is either `NONE', `DAILY', `MONTHLY' or `EACH_RUN'. MAX_CONNECTION *note Configuration options::. OPENED_V (vector tag) A list of boolean. One for each connection. True means that the socket is open. This is to be inserted in a template table. PEERNAME_V (vector tag) A list of peer name. One for each connection. This is the name of the last peer connected to the slot. QUIT_V (vector tag) A list of boolean. One for each connection. True means that the connection will terminate as soon as possible. This is to be inserted in a template table. RECEIVE_TIMEOUT *note Configuration options::. SECURITY A boolean set to True if this is a secure socket (HTTPS/SSL). SEND_TIMEOUT *note Configuration options::. SERVER_NAME *note Configuration options::. SERVER_PORT *note Configuration options::. SERVER_SOCK Server socket ID. SESSION_LIFETIME Number of seconds to keep session information. After this period a session is obsoleted and will be removed at next cleanup. SESSION_CLEANUP_INTERVAL Number of seconds between each run of the session cleanup task. This task will remove all session data that have been obsoleted. SESSIONS_TS_V (vector tag) A list of time stamp. Each item correspond to a session last access time. SESSIONS_TERMINATE_V (vector tag) A list of time. Each item correspond to the time when the session will be obsoleted. SESSIONS_V (vector tag) A list of session ID. SLOT_ACTIVITY_COUNTER_V (vector tag) A list of natural. One for each connection. This is the total number of requests the slot has answered. This counter is never reseted. SOCK_V (vector tag) A list of sockets ID. One for each connection. STATUS_PAGE *note Configuration options::. UPLOAD_DIRECTORY *note Configuration options::. VALUES_M (matrix tag) A list of set of values (for each value correspond a key in the vector tag KEYS_L, see above). Each key in the vector tag start with an HTML "" tag. This is to be able to display the key/value in column. VERSION `AWS' version string. There is also all `Templates_Parser' specific tags. This is not listed here please have a look at the `Templates_Parser' documentation distributed with `AWS'. References ********** Here is a list of documents used to implement `AWS', the `SOAP' support and associated services: RFC 0821 SIMPLE MAIL TRANSFER PROTOCOL Jonathan B. Postel August 1982 Information Sciences Institute University of Southern California 4676 Admiralty Way Marina del Rey, California 90291 RFC 1867 Network Working Group E. Nebel Request For Comments: 1867 L. Masinter Category: Experimental Xerox Corporation November 1995 Form-based File Upload in HTML RFC 1939 Network Working Group J. Myers Request for Comments: 1939 Carnegie Mellon STD: 53 M. Rose Obsoletes: 1725 Dover Beach Consulting, Inc. Category: Standards Track May 1996 Post Office Protocol - Version 3 RFC 1945 Network Working Group T. Berners-Lee Request for Comments: 1945 MIT/LCS Category: Informational R. Fielding UC Irvine H. Frystyk MIT/LCS May 1996 Hypertext Transfer Protocol -- HTTP/1.0 RFC 2049 Network Working Group N. Freed Request for Comments: 2049 Innosoft Obsoletes: 1521, 1522, 1590 N. Borenstein Category: Standards Track First Virtual November 1996 Multipurpose Internet Mail Extensions (MIME) Part Five: Conformance Criteria and Examples RFC 2109 Network Working Group D. Kristol Request for Comments: 2109 Bell Laboratories, Lucent Technologies Category: Standards Track L. Montulli Netscape Communications February 1997 HTTP State Management Mechanism RFC 2195 Network Working Group J. Klensin Request for Comments: 2195 R. Catoe Category: Standards Track P. Krumviede Obsoletes: 2095 MCI September 1997 IMAP/POP AUTHorize Extension for Simple Challenge/Response RFC 2554 Network Working Group J. Myers Request for Comments: 2554 Netscape Communications Category: Standards Track March 1999 SMTP Service Extension for Authentication RFC 2616 Network Working Group R. Fielding Request for Comments: 2616 UC Irvine Obsoletes: 2068 J. Gettys Category: Standards Track Compaq/W3C J. Mogul Compaq H. Frystyk W3C/MIT L. Masinter Xerox P. Leach Microsoft T. Berners-Lee W3C/MIT June 1999 Hypertext Transfer Protocol -- HTTP/1.1 RFC 2617 Network Working Group J. Franks Request for Comments: 2617 Northwestern University Obsoletes: 2069 P. Hallam-Baker Category: Standards Track Verisign, Inc. J. Hostetler AbiSource, Inc. S. Lawrence Agranat Systems, Inc. P. Leach Microsoft Corporation A. Luotonen Netscape Communications Corporation L. Stewart Open Market, Inc. June 1999 HTTP Authentication: Basic and Digest Access Authentication draft 302 Transport Layer Security Working Group Alan O. Freier INTERNET-DRAFT Netscape Communications Expire in six months Philip Karlton Netscape Communications Paul C. Kocher Independent Consultant November 18, 1996 The SSL Protocol Version 3.0 SOAP (W3C Note 08 May 2000) Simple Object Access Protocol (SOAP) 1.1 W3C Note 08 May 2000 This version: http://www.w3.org/TR/2000/NOTE-SOAP-20000508 Latest version: http://www.w3.org/TR/SOAP Authors (alphabetically): Don Box, DevelopMentor David Ehnebuske, IBM Gopal Kakivaya, Microsoft Andrew Layman, Microsoft Noah Mendelsohn, Lotus Development Corp. Henrik Frystyk Nielsen, Microsoft Satish Thatte, Microsoft Dave Winer, UserLand Software, Inc. Copyright© 2000 DevelopMentor, International Business Machines Corporation, Lotus Development Corporation, Microsoft, UserLand Software A Busy Developer's Guide to SOAP 1.1 By Dave Winer, Jake Savin, UserLand Software, 4/2/01. AWS API Reference ***************** AWS === ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2000-2004 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: aws.ads,v 1.41 2004/04/06 16:54:46 obry Exp $ package AWS is pragma Pure; Version : constant String := "2.0p"; HTTP_Version : constant String := "HTTP/1.1"; end AWS; AWS.Client ========== ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2000-2002 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: aws-client.ads,v 1.42 2003/12/17 14:38:06 obry Exp $ with Ada.Streams; with Ada.Strings.Unbounded; with AWS.Default; with AWS.Net.SSL.Certificate; with AWS.Response; with AWS.URL; package AWS.Client is Connection_Error : exception; -- Raised if the connection with the server cannot be established Protocol_Error : exception; -- Raised if the client receives wrong HTTP protocol data No_Data : constant String; -- Used as the default parameter when no data specified for a specific -- parameter. Retry_Default : constant := 0; -- Number of time a data is requested from the Server if the first -- time fails. type Authentication_Mode is new AWS.Response.Authentication_Mode; type Timeouts_Values is record Send : Natural; Receive : Natural; end record; -- Defined the number of seconds for the send and receive timeout No_Timeout : constant Timeouts_Values; -- No timeout, allow infinite time to send or retrieve data function Get (URL : in String; User : in String := No_Data; Pwd : in String := No_Data; Proxy : in String := No_Data; Proxy_User : in String := No_Data; Proxy_Pwd : in String := No_Data; Timeouts : in Timeouts_Values := No_Timeout; Follow_Redirection : in Boolean := False) return Response.Data; -- retrieve the message data given a specific URL. It open a connection -- with the server and ask for the resource specified in the URL it then -- return it in the Response.Data structure. -- If User/Pwd are given then it uses it to access the URL. -- -- Eventually it connect through a PROXY using if necessary the Proxy -- authentification Proxy_User:Proxy_Pwd. -- -- Only Basic authetification is supported (i.e. Digest is not). Digest -- authentication is supported with the keep-alive client API, see below. -- -- If Follow_Redirection is set to True, Get will follow the redirection -- information for 301 status code response. Note that this is not -- supported for keep-alive connections as the redirection could point to -- another server. -- -- Get will retry one time if it fails. function Head (URL : in String; User : in String := No_Data; Pwd : in String := No_Data; Proxy : in String := No_Data; Proxy_User : in String := No_Data; Proxy_Pwd : in String := No_Data; Timeouts : in Timeouts_Values := No_Timeout) return Response.Data; -- Idem as above but we do not get the message body. -- Head will retry one time if it fails. function Put (URL : in String; Data : in String; User : in String := No_Data; Pwd : in String := No_Data; Proxy : in String := No_Data; Proxy_User : in String := No_Data; Proxy_Pwd : in String := No_Data; Timeouts : in Timeouts_Values := No_Timeout) return Response.Data; -- Send to the server URL a PUT request with Data -- Put will retry one time if it fails. function Post (URL : in String; Data : in String; User : in String := No_Data; Pwd : in String := No_Data; Proxy : in String := No_Data; Proxy_User : in String := No_Data; Proxy_Pwd : in String := No_Data; Timeouts : in Timeouts_Values := No_Timeout) return Response.Data; -- Send to the server URL a POST request with Data -- Post will retry one time if it fails. function Post (URL : in String; Data : in Ada.Streams.Stream_Element_Array; User : in String := No_Data; Pwd : in String := No_Data; Proxy : in String := No_Data; Proxy_User : in String := No_Data; Proxy_Pwd : in String := No_Data; Timeouts : in Timeouts_Values := No_Timeout) return Response.Data; -- Idem as above but with binary data. function SOAP_Post (URL : in String; Data : in String; SOAPAction : in String; User : in String := No_Data; Pwd : in String := No_Data; Proxy : in String := No_Data; Proxy_User : in String := No_Data; Proxy_Pwd : in String := No_Data; Timeouts : in Timeouts_Values := No_Timeout) return Response.Data; -- Send to the server URL a POST request with Data -- Post will retry one time if it fails. function Upload (URL : in String; Filename : in String; User : in String := No_Data; Pwd : in String := No_Data; Proxy : in String := No_Data; Proxy_User : in String := No_Data; Proxy_Pwd : in String := No_Data; Timeouts : in Timeouts_Values := No_Timeout) return Response.Data; -- This is a file upload request. Filename file's content will be send to -- the server at address URL. --------------------------------------- -- Keep-Alive client implementation - --------------------------------------- type HTTP_Connection is limited private; procedure Create (Connection : in out HTTP_Connection; Host : in String; User : in String := No_Data; Pwd : in String := No_Data; Proxy : in String := No_Data; Proxy_User : in String := No_Data; Proxy_Pwd : in String := No_Data; Retry : in Natural := Retry_Default; Persistent : in Boolean := True; Timeouts : in Timeouts_Values := No_Timeout; Server_Push : in Boolean := False; Certificate : in String := Default.Client_Certificate; User_Agent : in String := Default.User_Agent); -- Create a new connection. This is to be used with Keep-Alive client API -- below. The connection will be tried Retry times if it fails. If -- persistent is True the connection will remain open otherwise it will be -- closed after each request. User/Pwd are the server authentication info, -- Proxy is the name of the proxy server to use, Proxy_USer/Proxy_Pwd are -- the proxy authentication data. Only Basic authentication is supported -- from this routine, for Digest authentication see below. Timeouts are -- the send/receive timeouts for each request. If Server_Push is True the -- connection will be used to push information to the client. -- Certificate can be set to specify the certificate filename to use for -- the secure connection. User_Agent can be overridden to whatever you want -- the client interface to present itself to the server. function Get_Certificate (Connection : in HTTP_Connection) return AWS.Net.SSL.Certificate.Object; -- Return the certificate used for the secure connection. If this is not a -- secure connection, returns Net.SSL.Certificate.Undefined. procedure Set_WWW_Authentication (Connection : in out HTTP_Connection; User : in String; Pwd : in String; Mode : in Authentication_Mode); -- Sets the username password and authentication mode for the Web -- authentication. -- -- "Any" mean that user want to use Digest server authentication mode but -- could use Basic if the server does not support Digest authentication. -- -- "Basic" mean that client will send basic authentication. "Basic" -- authentication is send with the first request and is a fast -- authentication protocol. -- -- "Digest" mean that the client ask for Digest authentication, it -- requires that a first unauthorized request be sent to the server. The -- server will answer "nonce" for the authentication protocol to continue. procedure Set_Proxy_Authentication (Connection : in out HTTP_Connection; User : in String; Pwd : in String; Mode : in Authentication_Mode); -- Sets the username, password and authentication mode for the proxy -- authentication. procedure Copy_Cookie (Source : in HTTP_Connection; Destination : in out HTTP_Connection); -- Copy a session ID from connection Source to connection Destination. -- Allow both connections to share the same user environment. Note that -- user's environment are thread-safe. function Read_Until (Connection : in HTTP_Connection; Delimiter : in String) return String; -- Read data on the Connection until the delimiter (including the -- delimiter). It can be used to retrieve the next piece of data from a -- push server. If returned data is empty or does not termintate with the -- delimiter the server push connection is closed. procedure Read_Until (Connection : in out HTTP_Connection; Delimiter : in String; Result : in out Ada.Strings.Unbounded.Unbounded_String); -- Idem as above but returns the result as an Unbounded_String. procedure Get (Connection : in out HTTP_Connection; Result : out Response.Data; URI : in String := No_Data); -- Same as Get above but using a Connection. procedure Head (Connection : in out HTTP_Connection; Result : out Response.Data; URI : in String := No_Data); -- Same as Head above but using a Connection. procedure Put (Connection : in out HTTP_Connection; Result : out Response.Data; Data : in String; URI : in String := No_Data); -- Same as Put above but using a Connection. procedure Post (Connection : in out HTTP_Connection; Result : out Response.Data; Data : in String; URI : in String := No_Data); -- Same as Post above but using a Connection. procedure Post (Connection : in out HTTP_Connection; Result : out Response.Data; Data : in Ada.Streams.Stream_Element_Array; URI : in String := No_Data); -- Same as Post above but using a Connection. procedure Upload (Connection : in out HTTP_Connection; Result : out Response.Data; Filename : in String; URI : in String := No_Data); -- Same as Upload above but using a Connection. procedure SOAP_Post (Connection : in HTTP_Connection; Result : out Response.Data; SOAPAction : in String; Data : in String); -- Same as SOAP_Post above but using a Connection. procedure Close (Connection : in out HTTP_Connection); -- Close connection, it releases all associated resources. procedure Set_Debug (On : in Boolean); -- Set debug mode on/off. If debug is activated the request header and the -- server response header will be displayed. private -- implementation removed end AWS.Client; AWS.Communication ================= ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2000-2003 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: aws-communication.ads,v 1.6 2003/11/09 08:29:10 obry Exp $ -- The communication protocol uses a light encoding scheme based on the HTTP -- GET method. For standard, XML based, communication you can use the SOAP -- protocol. This API can be convenient if you do not plan to build AWS with -- SOAP support. with Ada.Strings.Unbounded; package AWS.Communication is use Ada.Strings.Unbounded; type Parameter_Set is array (Positive range <>) of Unbounded_String; Null_Parameter_Set : constant Parameter_Set; function Parameters (P1, P2, P3, P4, P5 : in String := "") return Parameter_Set; -- Constructor function to help create a Parameter_Set. This function will -- return a Parameter_Set array containing any parameter with a non emptry -- string value. private -- implementation removed end AWS.Communication; AWS.Communication.Client ======================== ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2000-2003 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: aws-communication-client.ads,v 1.4 2003/03/02 14:22:31 obry Exp $ with AWS.Response; package AWS.Communication.Client is function Send_Message (Server : in String; Port : in Positive; Name : in String; Parameters : in Parameter_Set := Null_Parameter_Set) return Response.Data; -- Send a message to server with a set of parameters. The destination is -- server is http://Server:Port, the message name is Name and the set of -- parameters is to be found into Parameters. -- -- The complete message format is: -- -- http://:/AWS_Com?HOST=&NAME= -- &P1=&P2= end AWS.Communication.Client; AWS.Communication.Server ======================== ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2000-2003 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: aws-communication-server.ads,v 1.6 2003/03/02 14:22:20 obry Exp $ with AWS.Response; generic type T (<>) is limited private; -- Data type received by this server type T_Access is access T; with function Callback (Server : in String; Name : in String; Context : in T_Access; Parameters : in Parameter_Set := Null_Parameter_Set) return Response.Data; package AWS.Communication.Server is -- Each instantiation of this package will create an HTTP server waiting -- for incoming request at the Port specified in the Start formal -- parameter. This communication server must be started with the Start -- procedure and can be stopped with the procedure Shutdown below. procedure Start (Port : in Positive; Context : in T_Access); -- Start communication HTTP server listening at the given port procedure Shutdown; -- Shutdown the communication HTTP server end AWS.Communication.Server; AWS.Config ========== ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2000-2003 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: aws-config.ads,v 1.34 2003/12/20 11:52:23 obry Exp $ -- This package provide an easy way to handle server configuration options. -- -- If initialization of this package is not done all functions below will -- return the default value as declared in AWS.Default. with Ada.Strings.Unbounded; with AWS.Default; package AWS.Config is use Ada.Strings.Unbounded; type Object is private; Default_Config : constant Object; function Get_Current return Object; -- Returns a configuration record. This is the properties as read in files -- 'aws.ini' and 'progname.ini'. This configuration object holds only the -- per-server options. ------------------------ -- Per Server options - ------------------------ ------------ -- Server - ------------ function Server_Name (O : in Object) return String; pragma Inline (Server_Name); -- This is the name of the server as set by AWS.Server.Start function Server_Host (O : in Object) return String; pragma Inline (Server_Host); -- This is the server host. Can be used if the computer has a more than -- one IP address. It is possible to have two servers at the same port -- on the same machine, both being binded on different IP addresses. function Server_Port (O : in Object) return Positive; pragma Inline (Server_Port); -- This is the server port as set by the HTTP object declaration function Hotplug_Port (O : in Object) return Positive; pragma Inline (Hotplug_Port); -- This is the hotplug communication port needed to register and -- un-register an hotplug module. function Session (O : in Object) return Boolean; pragma Inline (Session); -- Returns True if the server session is activated function Case_Sensitive_Parameters (O : in Object) return Boolean; pragma Inline (Case_Sensitive_Parameters); -- HTTP parameters are case sensitive ---------------- -- Connection - ---------------- function Max_Connection (O : in Object) return Positive; pragma Inline (Max_Connection); -- This is the max simultaneous connections as set by the HTTP object -- declaration. function Free_Slots_Keep_Alive_Limit (O : in Object) return Positive; pragma Inline (Free_Slots_Keep_Alive_Limit); -- The minimum number of free slots where keep-alive connections are still -- enabled. After this limit no more keep-alive connection will be -- accepted by the server. This parameter must be used for heavy-loaded -- servers to make sure the server will never run out of slots. This limit -- must be less than Max_Connection. function Accept_Queue_Size (O : in Object) return Positive; pragma Inline (Accept_Queue_Size); -- This is the size of the queue for the incoming requests. Higher this -- value will be and less "connection refused" will be reported to the -- client. function Line_Stack_Size (O : in Object) return Positive; pragma Inline (Line_Stack_Size); -- HTTP lines stack size ---------- -- Data - ---------- function WWW_Root (O : in Object) return String; pragma Inline (WWW_Root); -- This is the root directory name for the server. This variable is not -- used internally by AWS. It is supposed to be used by the callback -- procedures who want to retrieve physical objects (images, Web -- pages...). The default value is the current working directory. function Upload_Directory (O : in Object) return String; pragma Inline (Upload_Directory); -- This point to the directory where uploaded files will be stored. The -- directory returned will end with a directory separator. function Directory_Browser_Page (O : in Object) return String; pragma Inline (Directory_Browser_Page); -- Filename for the directory browser template page --------- -- Log - --------- function Log_File_Directory (O : in Object) return String; pragma Inline (Log_File_Directory); -- This point to the directory where log files will be written. The -- directory returned will end with a directory separator. function Log_Filename_Prefix (O : in Object) return String; pragma Inline (Log_Filename_Prefix); -- This is the prefix to use for the log filename function Log_Split_Mode (O : in Object) return String; pragma Inline (Log_Split_Mode); -- This is split mode for the log file. Possible values are : Each_Run, -- Daily, Monthly and None. Any other values will raise an exception. function Error_Log_Filename_Prefix (O : in Object) return String; pragma Inline (Error_Log_Filename_Prefix); -- This is the prefix to use for the log filename. function Error_Log_Split_Mode (O : in Object) return String; pragma Inline (Error_Log_Split_Mode); -- This is split mode for the log file. Possible values are : Each_Run, -- Daily, Monthly and None. Any other values will raise an exception. ------------ -- Status - ------------ function Admin_URI (O : in Object) return String; pragma Inline (Admin_URI); -- This is the name of the admin server page as set by AWS.Server.Start. -- It is also known as the status page. function Status_Page (O : in Object) return String; pragma Inline (Status_Page); -- Filename for the status template page function Up_Image (O : in Object) return String; pragma Inline (Up_Image); -- Filename for the up arrow image used in the status page function Down_Image (O : in Object) return String; pragma Inline (Down_Image); -- Filename for the down arrow image used in the status page function Logo_Image (O : in Object) return String; pragma Inline (Logo_Image); -- Filename for the AWS logo image used in the status page -------------- -- Timeouts - -------------- function Cleaner_Wait_For_Client_Timeout (O : in Object) return Duration; pragma Inline (Cleaner_Wait_For_Client_Timeout); -- Number of seconds to timout on waiting for a client request. -- This is a timeout for regular cleaning task. function Cleaner_Client_Header_Timeout (O : in Object) return Duration; pragma Inline (Cleaner_Client_Header_Timeout); -- Number of seconds to timout on waiting for client header. -- This is a timeout for regular cleaning task. function Cleaner_Client_Data_Timeout (O : in Object) return Duration; pragma Inline (Cleaner_Client_Data_Timeout); -- Number of seconds to timout on waiting for client message body. -- This is a timeout for regular cleaning task. function Cleaner_Server_Response_Timeout (O : in Object) return Duration; pragma Inline (Cleaner_Server_Response_Timeout); -- Number of seconds to timout on waiting for client to accept answer. -- This is a timeout for regular cleaning task. function Force_Wait_For_Client_Timeout (O : in Object) return Duration; pragma Inline (Force_Wait_For_Client_Timeout); -- Number of seconds to timout on waiting for a client request. -- This is a timeout for urgent request when resources are missing. function Force_Client_Header_Timeout (O : in Object) return Duration; pragma Inline (Force_Client_Header_Timeout); -- Number of seconds to timout on waiting for client header. -- This is a timeout for urgent request when resources are missing. function Force_Client_Data_Timeout (O : in Object) return Duration; pragma Inline (Force_Client_Data_Timeout); -- Number of seconds to timout on waiting for client message body. -- This is a timeout for urgent request when resources are missing. function Force_Server_Response_Timeout (O : in Object) return Duration; pragma Inline (Force_Server_Response_Timeout); -- Number of seconds to timout on waiting for client to accept answer. -- This is a timeout for urgent request when resources are missing. function Send_Timeout (O : in Object) return Duration; pragma Inline (Send_Timeout); -- Number of seconds to timeout when sending chunck of data function Receive_Timeout (O : in Object) return Duration; pragma Inline (Receive_Timeout); -- Number of seconds to timeout when receiving chunck of data. -------------- -- Security - -------------- function Check_URL_Validity (O : in Object) return Boolean; pragma Inline (Check_URL_Validity); -- Server have to check URI for validity. For example it checks that an -- URL does not reference a resource above the Web root. function Security (O : in Object) return Boolean; pragma Inline (Security); -- Is the server working through th SSL function Certificate (O : in Object) return String; pragma Inline (Certificate); -- Returns the certificate to be used with the secure server. Returns the -- empty string if the server is not a secure one. function Key (O : in Object) return String; pragma Inline (Key); -- Returns the key to be used with the secure server. Returns the -- empty string if the server is not a secure one. function Security_Mode (O : in Object) return String; pragma Inline (Security_Mode); -- Returns the security mode to be used with the secure server. Returns the -- empty string if the server is not a secure one. function Exchange_Certificate (O : in Object) return Boolean; pragma Inline (Exchange_Certificate); -- Returns True if the client is requested to send its certificate to the -- server. Note that this option must not be used if the client is a Web -- Browser. ------------------------- -- Per Process options - ------------------------- function Session_Cleanup_Interval return Duration; pragma Inline (Session_Cleanup_Interval); -- Number of seconds between each run of the cleaner task to remove -- obsolete session data. function Session_Lifetime return Duration; pragma Inline (Session_Lifetime); -- Number of seconds to keep a session if not used. After this period the -- session data is obsoleted and will be removed during next cleanup. function Transient_Cleanup_Interval return Duration; pragma Inline (Transient_Cleanup_Interval); -- Number of seconds between each run of the cleaner task to remove -- transient pages. function Transient_Lifetime return Duration; pragma Inline (Transient_Lifetime); -- Number of seconds to keep a transient page. After this period the -- transient page is obsoleted and will be removed during next cleanup. private -- implementation removed end AWS.Config; AWS.Config.Ini ============== ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2000-2003 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: aws-config-ini.ads,v 1.7 2003/02/07 20:00:26 obry Exp $ -- Handle .ini style configuration file. In this file each option is on one -- line. The first word is the option name and the second one is the option -- value. package AWS.Config.Ini is procedure Read (Config : in out Object; Filename : in String); -- Read 'File_Name.ini' and update the configuration object with the -- options read from it. Raises Ada.Text_IO.Name_Error if Filename does -- not exist. end AWS.Config.Ini; AWS.Config.Set ============== ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2000-2003 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: aws-config-set.ads,v 1.19 2003/12/20 11:52:30 obry Exp $ -- This package can be used to Set any AWS parameters. package AWS.Config.Set is ------------------------ -- Per Server Options - ------------------------ ------------ -- Server - ------------ procedure Server_Name (O : in out Object; Value : in String); -- This is the name of the server as set by AWS.Server.Start procedure Server_Host (O : in out Object; Value : in String); -- This is the server host as set by the HTTP object declaration procedure Server_Port (O : in out Object; Value : in Positive); -- This is the server port as set by the HTTP object declaration procedure Hotplug_Port (O : in out Object; Value : in Positive); -- This is the hotplug communication port needed to register and -- un-register an hotplug module. procedure Session (O : in out Object; Value : in Boolean); -- Enable session handling is Value is True procedure Case_Sensitive_Parameters (O : in out Object; Value : in Boolean); -- Parameters are handled with the case if Value is True procedure Line_Stack_Size (O : in out Object; Value : in Positive); -- HTTP lines stack size ---------------- -- Connection - ---------------- procedure Max_Connection (O : in out Object; Value : in Positive); -- This is the max simultaneous connections as set by the HTTP object -- declaration. procedure Free_Slots_Keep_Alive_Limit (O : in out Object; Value : in Positive); -- The minimum number of free slots where keep-alive connections are still -- enabled. After this limit no more keep-alive connection will be -- accepted by the server. This parameter must be used for heavy-loaded -- servers to make sure the server will never run out of slots. This limit -- must be less than Max_Connection. procedure Accept_Queue_Size (O : in out Object; Value : in Positive); -- This is the size of the queue for the incoming requests. Higher this -- value will be and less "connection refused" will be reported to the -- client. ---------- -- Data - ---------- procedure WWW_Root (O : in out Object; Value : in String); -- This is the root directory name for the server. This variable is not -- used internally by AWS. It is supposed to be used by the callback -- procedures who want to retrieve physical objects (images, Web -- pages...). The default value is the current working directory. procedure Upload_Directory (O : in out Object; Value : in String); -- This point to the directory where uploaded files will be stored. The -- directory returned will end with a directory separator. procedure Directory_Browser_Page (O : in out Object; Value : in String); -- Filename for the directory browser template page. --------- -- Log - --------- procedure Log_File_Directory (O : in out Object; Value : in String); -- This point to the directory where log files will be written. The -- directory returned will end with a directory separator. procedure Log_Filename_Prefix (O : in out Object; Value : in String); -- This is the prefix to use for the log filename. procedure Log_Split_Mode (O : in out Object; Value : in String); -- This is split mode for the log file. Possible values are : Each_Run, -- Daily, Monthly and None. Any other values will raise an exception. procedure Error_Log_Filename_Prefix (O : in out Object; Value : in String); -- This is the prefix to use for the log filename. procedure Error_Log_Split_Mode (O : in out Object; Value : in String); -- This is split mode for the log file. Possible values are : Each_Run, -- Daily, Monthly and None. Any other values will raise an exception. ------------ -- Status - ------------ procedure Admin_URI (O : in out Object; Value : in String); -- This is the name of the admin server page as set by AWS.Server.Start procedure Status_Page (O : in out Object; Value : in String); -- Filename for the status template page procedure Up_Image (O : in out Object; Value : in String); -- Filename for the up arrow image used in the status page procedure Down_Image (O : in out Object; Value : in String); -- Filename for the down arrow image used in the status page procedure Logo_Image (O : in out Object; Value : in String); -- Filename for the AWS logo image used in the status page -------------- -- Timeouts - -------------- procedure Cleaner_Wait_For_Client_Timeout (O : in out Object; Value : in Duration); -- Number of seconds to timout on waiting for a client request. -- This is a timeout for regular cleaning task. procedure Cleaner_Client_Header_Timeout (O : in out Object; Value : in Duration); -- Number of seconds to timout on waiting for client header. -- This is a timeout for regular cleaning task. procedure Cleaner_Client_Data_Timeout (O : in out Object; Value : in Duration); -- Number of seconds to timout on waiting for client message body. -- This is a timeout for regular cleaning task. procedure Cleaner_Server_Response_Timeout (O : in out Object; Value : in Duration); -- Number of seconds to timout on waiting for client to accept answer. -- This is a timeout for regular cleaning task. procedure Force_Wait_For_Client_Timeout (O : in out Object; Value : in Duration); -- Number of seconds to timout on waiting for a client request. -- This is a timeout for urgent request when resources are missing. procedure Force_Client_Header_Timeout (O : in out Object; Value : in Duration); -- Number of seconds to timout on waiting for client header. -- This is a timeout for urgent request when resources are missing. procedure Force_Client_Data_Timeout (O : in out Object; Value : in Duration); -- Number of seconds to timout on waiting for client message body. -- This is a timeout for urgent request when resources are missing. procedure Force_Server_Response_Timeout (O : in out Object; Value : in Duration); -- Number of seconds to timout on waiting for client to accept answer. -- This is a timeout for urgent request when resources are missing. procedure Send_Timeout (O : in out Object; Value : in Duration); -- Number of seconds to timeout when sending chunck of data. procedure Receive_Timeout (O : in out Object; Value : in Duration); -- Number of seconds to timeout when receiving chunck of data. -------------- -- Security - -------------- procedure Check_URL_Validity (O : in out Object; Value : in Boolean); -- Set the check URL validity flag. If True an URL that reference a -- resource above the Web root will be rejected. procedure Security (O : in out Object; Value : in Boolean); -- Enable security (HTTPS/SSL) if Value is True procedure Certificate (O : in out Object; Filename : in String); -- Set the certificate to be used with the secure server procedure Key (O : in out Object; Filename : in String); -- Set the key to be used with the secure server procedure Security_Mode (O : in out Object; Mode : in String); -- Set the security mode to be used with the secure server. Only values -- from AWS.Net.SSL.Method can be used. procedure Exchange_Certificate (O : in out Object; Value : in Boolean); -- Set to True to request the client to send its certificate to the server ------------------------- -- Per Process Options - ------------------------- procedure Session_Cleanup_Interval (Value : in Duration); -- Number of seconds between each run of the cleaner task to remove -- obsolete session data. procedure Session_Lifetime (Value : in Duration); -- Number of seconds to keep a session if not used. After this period the -- session data is obsoleted and will be removed during next cleanup. procedure Transient_Cleanup_Interval (Value : in Duration); -- Number of seconds between each run of the cleaner task to remove -- transient pages. procedure Transient_Lifetime (Value : in Duration); -- Number of seconds to keep a transient page. After this period the -- transient page is obsoleted and will be removed during next cleanup. procedure Parameter (Config : in out Object; Name : in String; Value : in String; Error_Context : in String := ""); -- Set one of the AWS HTTP per server parameters. Raises Constraint_Error -- in case of wrong parameter name or wrong parameter value. -- Error_Context may contain additional information about the parameter. -- This message will be added to the Constraint_Error exception. -- One way to use Error_Context is to set it with information about -- where this parameter come form. procedure Parameter (Name : in String; Value : in String; Error_Context : in String := ""); -- Set one of the AWS HTTP per process parameters. See description above end AWS.Config.Set; AWS.Containers.Tables ===================== ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2000-2003 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: aws-containers-tables.ads,v 1.15 2003/10/20 22:39:54 anisimko Exp $ with Ada.Strings.Unbounded; with GNAT.Dynamic_Tables; with Table_Of_Strings_And_Static_Values_G; package AWS.Containers.Tables is type Table_Type is tagged private; type Element (Name_Length, Value_Length : Natural) is record Name : String (1 .. Name_Length); Value : String (1 .. Value_Length); end record; -- Data type to store name/value pair retrieved from a Table_Type Null_Element : constant Element; type VString_Array is array (Positive range <>) of Ada.Strings.Unbounded.Unbounded_String; function Count (Table : in Table_Type) return Natural; -- Returns the number of item in Table. function Name_Count (Table : in Table_Type) return Natural; -- Returns the number of unique key name in Table. function Count (Table : in Table_Type; Name : in String) return Natural; -- Returns the number of value for Key Name in Table. It returns -- 0 if Key does not exist. function Exist (Table : in Table_Type; Name : in String) return Boolean; -- Returns True if Key exist in Table. function Get (Table : in Table_Type; Name : in String; N : in Positive := 1) return String; -- Returns the Nth value associated with Key into Table. Returns -- the emptry string if key does not exist. function Get_Name (Table : in Table_Type; N : in Positive := 1) return String; -- Returns the Nth Name in Table or the empty string if there is -- no parameter with this number. function Get_Value (Table : in Table_Type; N : in Positive := 1) return String; -- Returns the Nth Value in Table or the empty string if there is -- no parameter with this number. function Get (Table : in Table_Type; N : in Positive) return Element; -- Returns N'th name/value pair. Returns Null_Element if there is no -- such item in the table. function Get_Names (Table : in Table_Type; Sort : in Boolean := False) return VString_Array; -- Returns array of unique key names. If Sort is True, the returned names -- array is sorted in alphabetical order. This is of course slightly -- slower than returning unsorted results. function Get_Values (Table : in Table_Type; Name : in String) return VString_Array; -- Returns all values for the specified parameter key name. private -- implementation removed end AWS.Containers.Tables; AWS.Default =========== ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2000-2003 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: aws-default.ads,v 1.17 2003/12/17 14:37:40 obry Exp $ -- This package contains the default AWS configuration values. These values -- are used to initialize the configuration objects. Users should not modify -- the values here, see AWS.Config.* API. package AWS.Default is pragma Pure; -- All times are in seconds One_Hour : constant := 3_600.0; One_Minute : constant := 60.0; Eight_Hours : constant := 8.0 * One_Hour; Three_Hours : constant := 3.0 * One_Hour; Three_Minutes : constant := 3.0 * One_Minute; Five_Minutes : constant := 5.0 * One_Minute; Ten_Minutes : constant := 10.0 * One_Minute; -- Server configuration Server_Name : constant String := "AWS Module"; WWW_Root : constant String := "./"; Admin_URI : constant String := ""; Server_Port : constant := 8080; Hotplug_Port : constant := 8888; Max_Connection : constant := 5; Free_Slots_Keep_Alive_Limit : constant := 1; Accept_Queue_Size : constant := 64; Upload_Directory : constant String := "./"; Line_Stack_Size : constant := 16#150_000#; Case_Sensitive_Parameters : constant Boolean := True; -- Client configuration User_Agent : constant String := "AWS (Ada Web Server) v" & Version; -- Log values. The character '@' in the error log filename prefix is -- replaced by the running program name. Log_File_Directory : constant String := "./"; Log_Split_Mode : constant String := "NONE"; Log_Filename_Prefix : constant String := "@"; Error_Log_Split_Mode : constant String := "NONE"; Error_Log_Filename_Prefix : constant String := "@_error"; -- Session Session : constant Boolean := False; Session_Cleanup_Interval : constant Duration := Five_Minutes; Session_Lifetime : constant Duration := Ten_Minutes; -- Transient pages Transient_Cleanup_Interval : constant Duration := Three_Minutes; Transient_Lifetime : constant Duration := Five_Minutes; -- Server's timeouts Cleaner_Wait_For_Client_Timeout : constant Duration := 80.0; Cleaner_Client_Header_Timeout : constant Duration := 20.0; Cleaner_Client_Data_Timeout : constant Duration := Eight_Hours; Cleaner_Server_Response_Timeout : constant Duration := Eight_Hours; Force_Wait_For_Client_Timeout : constant Duration := 2.0; Force_Client_Header_Timeout : constant Duration := 3.0; Force_Client_Data_Timeout : constant Duration := Three_Hours; Force_Server_Response_Timeout : constant Duration := Three_Hours; Send_Timeout : constant Duration := 40.0; Receive_Timeout : constant Duration := 30.0; -- Directory template Directory_Browser_Page : constant String := "aws_directory.thtml"; -- Status page Status_Page : constant String := "aws_status.thtml"; Up_Image : constant String := "aws_up.png"; Down_Image : constant String := "aws_down.png"; Logo_Image : constant String := "aws_logo.png"; -- Security Security : constant Boolean := False; Security_Mode : constant String := "SSLv23"; Certificate : constant String := "cert.pem"; Key : constant String := ""; Client_Certificate : constant String := "client.pem"; Exchange_Certificate : constant Boolean := False; Check_URL_Validity : constant Boolean := True; end AWS.Default; AWS.Dispatchers =============== ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2000-2003 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: aws-dispatchers.ads,v 1.4 2003/10/09 15:13:21 obry Exp $ -- This package provides a service to build Callbacks which can support -- user's data. It is possible to build a new dispatcher by inheriting the -- handler type and to provides the Dispatch routine. with Ada.Finalization; with AWS.Response; with AWS.Status; package AWS.Dispatchers is type Handler is abstract new Ada.Finalization.Controlled with private; procedure Initialize (Dispatcher : in out Handler); procedure Adjust (Dispatcher : in out Handler); procedure Finalize (Dispatcher : in out Handler); -- Initialize/Adjust/Finalize is doing the reference counting, children -- should just call these routines if possible. It is possible to know if -- no more object are referenced by calling Ref_Counter below. function Dispatch (Dispatcher : in Handler; Request : in Status.Data) return Response.Data is abstract; -- Call the appropriate inherited dispatcher function Ref_Counter (Dispatcher : in Handler) return Natural; -- Returns the reference counter for Handler. If 0 is returned then this -- object is not referenced anymore, it is safe to deallocate ressources. type Handler_Class_Access is access all Handler'Class; procedure Free (Dispatcher : in out Handler_Class_Access); pragma Inline (Free); -- Release memory associated with the dispatcher private -- implementation removed end AWS.Dispatchers; AWS.Dispatchers.Callback ======================== ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2000-2001 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: aws-dispatchers-callback.ads,v 1.2 2002/12/04 10:57:31 obry Exp $ -- Dispatch on a Callback procedure. with AWS.Dispatchers; with AWS.Response; with AWS.Status; package AWS.Dispatchers.Callback is type Handler is new Dispatchers.Handler with private; -- This is a simple wrapper around standard callback procedure (access to -- function). It will be used to build dispatchers services and for the -- main server callback. function Create (Callback : in Response.Callback) return Handler; pragma Inline (Create); -- Build a dispatcher for the specified callback. function Dispatch (Dispatcher : in Handler; Request : in Status.Data) return Response.Data; private -- implementation removed end AWS.Dispatchers.Callback; AWS.Exceptions ============== ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2003 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: aws-exceptions.ads,v 1.2 2003/01/31 18:17:27 obry Exp $ with Ada.Exceptions; with AWS.Log; with AWS.Response; with AWS.Status; package AWS.Exceptions is type Data is record Fatal : Boolean; -- If True it means that we go a fatal error. The slot will be -- terminated so AWS will loose one of it's simultaneous connection. -- This is clearly an AWS internal error that should be fixed in AWS. Slot : Positive; -- The failing slot number Request : Status.Data; -- The complete request information that was served when the slot has -- failed. This variable is set only when Fatal is False. end record; type Unexpected_Exception_Handler is access procedure (E : in Ada.Exceptions.Exception_Occurrence; Log : in out AWS.Log.Object; Error : in Data; Answer : in out Response.Data); -- Unexpected exception handler can be set to monitor server errors. -- Answer can be set with the answer to send back to the client's -- browser. Note that this is possible only for non fatal error -- (i.e. Error.Fatal is False). -- Log is the error log object for the failing server, it can be used -- to log user's information (if error log is activated for this -- server). Note that the server will have already logged information -- about the problem. end AWS.Exceptions; AWS.Headers =========== ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2000-2001 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: aws-headers.ads,v 1.13 2003/11/05 08:45:56 obry Exp $ with AWS.Containers.Tables; with AWS.Net; package AWS.Headers is type List is new AWS.Containers.Tables.Table_Type with private; -- Header container. This set handles a set of HTTP header line, each new -- header line is inserted at the end of the list (see AWS.Headers.Set API) -- and can be retrieved by the following services. Header lines are -- numbered from 1 to N. subtype VString_Array is AWS.Containers.Tables.VString_Array; subtype Element is AWS.Containers.Tables.Element; Format_Error : exception; -- Raised when header line format is wrong procedure Send_Header (Socket : in Net.Socket_Type'Class; Headers : in List); -- Send all header lines in Headers list to the socket function Get_Line (Headers : in List; N : in Positive) return String; -- Returns the Nth header line in Headers container. The returned value is -- formatted as a correct header line: -- -- message-header = field-name ":" [ field-value ] -- -- That is the header-name followed with character ':' and the header -- values. If there is less than Nth header line it returns the empty -- string. Note that this routine does returns all header line values, for -- example it would return: -- -- Content_Type: multipart/mixed; boundary="0123_The_Boundary_Value_" -- -- For a file upload content type header style. function Get_Values (Headers : in List; Name : in String) return String; -- Returns all values for the specified header field Name in a -- comma-separated string. This format is conformant to [RFC 2616 - 4.2] -- (see last paragraph). -- See AWS.Containers.Tables for inherited routines. private -- implementation removed end AWS.Headers; AWS.Headers.Values ================== ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2002-2003 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: aws-headers-values.ads,v 1.8 2003/03/01 18:29:47 obry Exp $ with Ada.Strings.Unbounded; package AWS.Headers.Values is use Ada.Strings.Unbounded; -- Data represent a token from an header line. There is two kinds of -- token, either named or un-named. -- -- Content-Type: xyz boundary="uvt" -- -- Here xyz is an un-named value and uvt a named value the name is -- boundary. type Data (Named_Value : Boolean := True) is record Value : Unbounded_String; case Named_Value is when True => Name : Unbounded_String; when False => null; end case; end record; type Set is array (Positive range <>) of Data; ----------- -- Parse - ----------- generic with procedure Value (Item : in String; Quit : in out Boolean); -- Called for every un-named value read from the header value with procedure Named_Value (Name : in String; Value : in String; Quit : in out Boolean); -- Called for every named value read from the header value procedure Parse (Header_Value : in String); -- Look for un-named values and named ones (Name="Value" pairs) in the -- header line, and call appropriate routines when found. Quit is set to -- False before calling Value or Named_Value, the parsing can be stopped -- by setting Quit to True. ------------------- -- Split / Index - ------------------- function Split (Header_Value : in String) return Set; -- Returns a Set with each named and un-named values splited from Data. function Index (Set : in Values.Set; Name : in String; Case_Sensitive : in Boolean := True) return Natural; -- Returns index for Name in the set or 0 if Name not found. -- If Case_Sensitive is false the find is case_insensitive. --------------------------- -- Other search routines - --------------------------- function Search (Header_Value : in String; Name : in String; Case_Sensitive : in Boolean := True) return String; -- Returns Value for Name in Header_Value or the empty string if Name not -- found. If Case_Sensitive is False the search is case insensitive. function Get_Unnamed_Value (Header_Value : in String; N : in Positive := 1) return String; -- Returns N-th un-named value from Header_Value. function Unnamed_Value_Exists (Header_Value : in String; Value : in String; Case_Sensitive : in Boolean := True) return Boolean; -- Returns True if the unnamed value specified has been found in -- Header_Value. end AWS.Headers.Values; AWS.Jabber ========== ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2002-2003 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: aws-jabber.ads,v 1.1 2003/07/07 17:29:23 obry Exp $ with Ada.Strings.Unbounded; with AWS.Containers.Key_Value; with AWS.Net; with AWS.Utils; package AWS.Jabber is type Server is limited private; -- This is the Jabber server connection. This object is initialized by -- Connect below and is used with all services. Default_Port : constant := 5222; -- Standard Jabber Server default port is 5222. The SSL based connection -- port is 5223 but this is not supported by this API. Server_Error : exception; -- Raised by any routine below when an server or protocol error occurs. A -- message is attached to the exception, this correspond to the -- XML protocol tag if present. procedure Connect (Server : in out Jabber.Server; Host : in String; User : in String; Password : in String; Port : in Positive := Default_Port); -- Connect to a Jabber server Host:Port using User/Password account. It -- returns the Server object which can be used with services below. procedure Close (Server : in out Jabber.Server); -- Close the connection with the Jabber server. procedure Send_Message (Server : in Jabber.Server; JID : in String; Subject : in String; Content : in String); -- Send a message to user JID (Jabber ID) via the specified Server. The -- message is composed of Subject and a body (Content). type Presence_Status is (Offline, Available, Chat, Away, Extended_Away, Do_Not_Disturb); procedure Check_Presence (Server : in Jabber.Server; JID : in String; Status : out Presence_Status); -- Returns the presence status for JID. private -- implementation removed end AWS.Jabber; AWS.LDAP.Client =============== ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2003 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: aws-ldap-client.ads,v 1.9 2003/09/06 13:31:12 obry Exp $: -- Provides an API to read information from an LDAP server. This API does not -- cover modifing, adding or deleting information into the server. It is a -- thick binding, see AWS.LDAP.Thin for a thin binding. -- -- This API has been tested on Windows and Linux (OpenLDAP). with Ada.Exceptions; with Ada.Strings.Unbounded; with AWS.LDAP.Thin; package AWS.LDAP.Client is use Ada.Strings.Unbounded; Default_Port : constant Positive := Positive (Thin.LDAP_PORT); subtype Directory is Thin.LDAP_Type; -- An LDAP directory. This object must be initialized with Init and Bind -- and terminated with Unbind. subtype LDAP_Message is Thin.LDAPMessage; -- An LDAP message or set of messages. There is a set of iterators to -- access all messages returned by the search procedure. subtype BER_Element is Thin.BerElement; -- An iterator structure. Initialized and used to iterate through all the -- attributes for a specific message. Null_Directory : constant Directory := Thin.Null_LDAP_Type; Null_LDAP_Message : constant LDAP_Message := Thin.Null_LDAPMessage; type Scope_Type is (LDAP_Scope_Default, LDAP_Scope_Base, LDAP_Scope_One_Level, LDAP_Scope_Subtree); -- LDAP scope for the search type String_Set is array (Positive range <>) of Unbounded_String; -- A set of strings, this is used to map C array of strings (a char **) -- from the thin binding. Null_Set : constant String_Set; function Get_Error (E : in Ada.Exceptions.Exception_Occurrence) return Thin.Return_Code; -- Returns the error code in the LDAP_Error exception occurence E. Returns -- Think.LDAP_SUCCESS if no error code has been found. ---------------- -- Attributes - ---------------- subtype Attribute_Set is String_Set; -- Used to represent the set of attributes to retrieve from the LDAP server function Attributes (S1, S2, S3, S4, S5, S6, S7, S8, S9, S10 : in String := "") return Attribute_Set; -- Returns a String_Set object containing only none empty values. Values -- for S1 through S10 must be set in the order of the parameters. This is -- an helper routine to help building an array of unbounded string from a -- set of string. function uid (Val : in String := "") return String; -- Returns the uid attribute, if Val is specified "=" is -- added after the attribute name. function givenName (Val : in String := "") return String; -- Returns the given name (firstname) attribute. if Val is specified -- "=" is added after the attribute name. function cn (Val : in String := "") return String; function commonName (Val : in String := "") return String renames cn; -- Returns the common Name attribute, if Val is specified "=" is -- added after the attribute name. function sn (Val : in String := "") return String; function surname (Val : in String := "") return String renames sn; -- Returns the surname attribute, if Val is specified "=" is -- added after the attribute name. function telephoneNumber (Val : in String := "") return String; -- Returns the phone number. if Val is specified "=" is -- added after the attribute name. Val must use the international notation -- according to CCITT E.123. function mail (Val : in String := "") return String; -- Returns the mail attribute. if Val is specified "=" is added after -- the attribute name. function l (Val : in String := "") return String; function localityName (Val : in String := "") return String renames l; -- Returns the locality attribute, if Val is specified "=" is -- added after the attribute name. function o (Val : in String := "") return String; function organizationName (Val : in String := "") return String renames o; -- Returns the organization attribute, if Val is specified "=" is -- added after the attribute name. function ou (Val : in String := "") return String; function organizationalUnitName (Val : in String := "") return String renames ou; -- Returns the organizational unit attribute, if Val is specified "=" -- is added after the attribute name. function st (Val : in String := "") return String; function stateOrProvinceName (Val : in String := "") return String renames st; -- Returns the state name attribute, if Val is specified "=" is -- added after the attribute name. function c (Val : in String := "") return String; function countryName (Val : in String) return String renames c; -- Returns country code attribute, if Val is specified "=" is -- added after the attribute name. Val must be a two-letter ISO 3166 -- country code. function dc (Val : in String := "") return String; function domainComponent (Val : in String := "") return String renames dc; -- Returns a domain component attribute, if Val is specified "=" is -- added after the attribute name. function Cat (S1, S2, S3, S4, S5, S6, S7, S8, S9, S10 : in String := "") return String; -- Returns a string object containing only none empty values. Values for -- S1 through S10 must be set in the order of the parameters. All values -- are catenated and separated with a coma. This is an helper routine to -- help building a filter objects or base distinguished name. ---------------- -- Initialize - ---------------- function Init (Host : in String; Port : in Positive := Default_Port) return Directory; -- Must be called first, to initialize the LDAP communication with the -- server. Returns Null_Directory in case of error. procedure Bind (Dir : in out Directory; Login : in String; Password : in String); -- Bind to the server by providing a login and password procedure Unbind (Dir : in out Directory); -- Must be called to release resources associated with the Directory. Does -- nothing if Dir is Null_Directory. function Is_Open (Dir : in Directory) return Boolean; -- Returns True if the directory has correctly been initialized and binded -- with the server. ------------ -- Search - ------------ function Search (Dir : in Directory; Base : in String; Filter : in String; Scope : in Scope_Type := LDAP_Scope_Default; Attrs : in Attribute_Set := Null_Set; Attrs_Only : in Boolean := False) return LDAP_Message; -- Do a search on the LDAP server. Base is the name of the database. -- Filter can be used to retrieve a specific set of entries. Attrs specify -- the set of attributes to retrieve. If Attrs_Only is set to True only -- the types are returned. Raises LDAP_Error in case of problem. --------------- -- Iterators - --------------- function First_Entry (Dir : in Directory; Chain : in LDAP_Message) return LDAP_Message; -- Returns the first entry (or Node) for the search result (Chain). function Next_Entry (Dir : in Directory; Entries : in LDAP_Message) return LDAP_Message; -- Returns next entry (or Node) for Entries. function Count_Entries (Dir : in Directory; Chain : in LDAP_Message) return Natural; -- Returns the number of entries in the search result (Chain). procedure Free (Chain : in LDAP_Message); -- Release memory associated with the search result Chain. generic with procedure Action (Node : in LDAP_Message; Quit : in out Boolean); procedure For_Every_Entry (Dir : in Directory; Chain : in LDAP_Message); -- This iterator call Action for each entry (Node) found in the LDAP result -- set as returned by the search procedure. Quit can be set to True to -- stop iteration; its initial value is False. function First_Attribute (Dir : in Directory; Node : in LDAP_Message; BER : access BER_Element) return String; -- Returns the first attribute for the entry. It initialize an iteraror -- (the BER structure). The BER structure must be released after used by -- using the Free routine below. function Next_Attribute (Dir : in Directory; Node : in LDAP_Message; BER : in BER_Element) return String; -- Returns next attribute for iterator BER. First_Attribute must have been -- called to initialize this iterator. procedure Free (BER : in BER_Element); -- Releases memory associated with the BER structure which has been -- allocated by the First_Attribute routine. generic with procedure Action (Attribute : in String; Quit : in out Boolean); procedure For_Every_Attribute (Dir : in Directory; Node : in LDAP_Message); -- This iterator call action for each attribute found in the LDAP Entries -- Node as returned by First_Entry or Next_Entry. Quit can be set to True -- to stop iteration; its initial value is False. --------------- -- Accessors - --------------- function Get_DN (Dir : in Directory; Node : in LDAP_Message) return String; -- Returns the distinguished name for the given entry Node. function DN2UFN (DN : in String) return String; -- Returns a distinguished name converted to a user-friendly format function Get_Values (Dir : in Directory; Node : in LDAP_Message; Target : in String) return String_Set; -- Returns the list of values of a given attribute (Target) found in entry -- Node. function Explode_DN (DN : in String; No_Types : in Boolean := True) return String_Set; -- Breaks up an entry name into its component parts. If No_Types is set to -- True the types information ("cn=") won't be included. private -- implementation removed end AWS.LDAP.Client; AWS.Log ======= ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2000-2003 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: aws-log.ads,v 1.18 2003/10/10 05:36:23 obry Exp $ -- This package handle the logging facility for AWS. The log file is named -- '-Y-M-D.log' and is written by default in the directory where -- the server is launched, see configuration file. -- -- Note that this package is used internally by AWS to log server requests -- but it can also be used by users to handle application's log. -- -- This package is thread safe. with Ada.Text_IO; with Ada.Strings.Unbounded; with AWS.Status; with AWS.Response; with AWS.Messages; with AWS.Utils; package AWS.Log is type Object is limited private; -- A log object. It must be activated by calling Start below type Split_Mode is (None, Each_Run, Daily, Monthly); -- It specifies when to create a new log file. -- None : all log info gets accumulated into the same file. -- Each_Run : a new log file is created each time the server is started. -- Daily : a new log file is created each day. -- Monthly : a new log file is created each month. Not_Specified : constant String; procedure Start (Log : in out Object; Split : in Split_Mode := None; File_Directory : in String := Not_Specified; Filename_Prefix : in String := Not_Specified; Auto_Flush : in Boolean := False); -- Activate server's activity logging. Split indicate the way the log file -- should be created. Log_File_Prefix is the log filename prefix. If it is -- not specified the default prefix is the program name. -- Set Auto_Flush to True if you want every write to the log to be flushed -- (not buffered). Auto_Flush should be set to True only for logs with few -- entries per second as the flush has a performance penalty. procedure Write (Log : in out Object; Connect_Stat : in Status.Data; Answer : in Response.Data); -- Write log info if activated (i.e. Start routine above has been called) procedure Write (Log : in out Object; Connect_Stat : in Status.Data; Status_Code : in Messages.Status_Code; Content_Length : in Natural); -- Write log info if activated (i.e. Start routine above has been called). -- This version separated the Content_Length from Status.Data, this is -- required for example in the case of a user defined stream content. See -- AWS.Resources.Stream. procedure Write (Log : in out Object; Connect_Stat : in Status.Data; Data : in String); -- Write user's log info if activated. (i.e. Start routine above has been -- called). procedure Write (Log : in out Object; Data : in String); -- Write Data into the log file. This Data is unstructured, only a time -- tag prefix is prepended to Data. This routine is designed to be used -- for user's info in error log file. procedure Flush (Log : in out Object); -- Flush the data to the Log file, for be able to see last logged -- messages. procedure Stop (Log : in out Object); -- Stop logging activity function Is_Active (Log : in Object) return Boolean; -- Returns True if Log is activated function Filename (Log : in Object) return String; -- Returns current log filename or the empty string if the log is not -- activated. function Mode (Log : in Object) return Split_Mode; -- Returns the split mode. None will be returned if log is not activated. private -- implementation removed end AWS.Log; AWS.Messages ============ ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2000-2004 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: aws-messages.ads,v 1.34 2004/01/25 10:35:13 obry Exp $ with Ada.Calendar; package AWS.Messages is use Ada; ----------------- -- HTTP tokens - ----------------- HTTP_Token : constant String := "HTTP/"; Get_Token : constant String := "GET "; Head_Token : constant String := "HEAD "; Post_Token : constant String := "POST "; ------------------------ -- HTTP header tokens - ------------------------ -- General header tokens RFC 2616 Cache_Control_Token : constant String := "Cache-Control"; Connection_Token : constant String := "Connection"; Date_Token : constant String := "Date"; Pragma_Token : constant String := "Pragma"; Trailer_Token : constant String := "Trailer"; Transfer_Encoding_Token : constant String := "Transfer-Encoding"; Upgrade_Token : constant String := "Upgrade"; Via_Token : constant String := "Via"; Warning_Token : constant String := "Warning"; -- Request header tokens RFC 2616 Accept_Token : constant String := "Accept"; Accept_Charset_Token : constant String := "Accept-Charset"; Accept_Encoding_Token : constant String := "Accept-Encoding"; Accept_Language_Token : constant String := "Accept-Language"; Authorization_Token : constant String := "Authorization"; Expect_Token : constant String := "Expect"; From_Token : constant String := "From"; Host_Token : constant String := "Host"; If_Match_Token : constant String := "If-Match"; If_Modified_Since_Token : constant String := "If-Modified-Since"; If_None_Match_Token : constant String := "If-None-Match"; If_Range_Token : constant String := "If-Range"; If_Unmodified_Since_Token : constant String := "If-Unmodified-Since"; Max_Forwards_Token : constant String := "Max-Forwards"; Proxy_Authorization_Token : constant String := "Proxy-Authorization"; Range_Token : constant String := "Range"; Referer_Token : constant String := "Referer"; TE_Token : constant String := "TE"; User_Agent_Token : constant String := "User-Agent"; -- Response header tokens RFC 2616 Accept_Ranges_Token : constant String := "Accept-Ranges"; Age_Token : constant String := "Age"; ETag_Token : constant String := "ETag"; Location_Token : constant String := "Location"; Proxy_Authenticate_Token : constant String := "Proxy-Authenticate"; Retry_After_Token : constant String := "Retry-After"; Server_Token : constant String := "Server"; Vary_Token : constant String := "Vary"; WWW_Authenticate_Token : constant String := "WWW-Authenticate"; -- Entity header tokens RFC 2616 Allow_Token : constant String := "Allow"; Content_Encoding_Token : constant String := "Content-Encoding"; Content_Language_Token : constant String := "Content-Language"; Content_Length_Token : constant String := "Content-Length"; Content_Location_Token : constant String := "Content-Location"; Content_MD5_Token : constant String := "Content-MD5"; Content_Range_Token : constant String := "Content-Range"; Content_Type_Token : constant String := "Content-Type"; Expires_Token : constant String := "Expires"; Last_Modified_Token : constant String := "Last-Modified"; -- Other tokens Proxy_Connection_Token : constant String := "Proxy-Connection"; Content_Disposition_Token : constant String := "Content-Disposition"; Cookie_Token : constant String := "Cookie"; Set_Cookie_Token : constant String := "Set-Cookie"; SOAPAction_Token : constant String := "SOAPAction"; Content_Transfer_Encoding_Token : constant String := "Content-Transfer-Encoding"; ----------------- -- Status Code - ----------------- type Status_Code is (S100, S101, -- 1xx : Informational - Request received, continuing process S200, S201, S202, S203, S204, S205, S206, -- 2xx : Success - The action was successfully received, understood and -- accepted S300, S301, S302, S303, S304, S305, S307, -- 3xx : Redirection - Further action must be taken in order to -- complete the request S400, S401, S402, S403, S404, S405, S406, S407, S408, S409, S410, S411, S412, S413, S414, S415, S416, S417, -- 4xx : Client Error - The request contains bad syntax or cannot be -- fulfilled S500, S501, S502, S503, S504, S505 -- 5xx : Server Error - The server failed to fulfill an apparently -- valid request ); function Image (S : in Status_Code) return String; -- Returns Status_Code image. This value does not contain the leading S. function Reason_Phrase (S : in Status_Code) return String; -- Returns the reason phrase for the status code S, see [RFC 2616 - 6.1.1] ---------------------- -- Content encoding - ---------------------- type Content_Encoding is (Identity, GZip, Deflate); -- Encoding mode for the response, Identity means that no encoding is -- done, Gzip/Deflate to select the Gzip or Deflate encoding algorithm. ------------------- -- Cache_Control - ------------------- type Cache_Option is new String; -- Cache_Option is a string and any specific option can be specified. We -- define three options: -- -- Unspecified : No cache option will used. -- No_Cache : Ask browser and proxy to not cache data (no-cache, -- max-age, and s-maxage are specified). -- No_Store : Ask browser and proxy to not store any data. This can be -- used to protect sensitive data. -- Prevent_Cache : Equivalent to No_Store + No_Cache Unspecified : constant Cache_Option; No_Cache : constant Cache_Option; No_Store : constant Cache_Option; Prevent_Cache : constant Cache_Option; ------------------------------- -- HTTP message constructors - ------------------------------- function Accept_Type (Mode : in String) return String; pragma Inline (Accept_Type); function Accept_Language (Mode : in String) return String; pragma Inline (Accept_Language); function Authorization (Mode, Password : in String) return String; pragma Inline (Authorization); function Connection (Mode : in String) return String; pragma Inline (Connection); function Content_Length (Size : in Natural) return String; pragma Inline (Content_Length); function Cookie (Value : in String) return String; pragma Inline (Cookie); function Content_Type (Format : in String; Boundary : in String := "") return String; pragma Inline (Content_Type); function Cache_Control (Option : in Cache_Option) return String; pragma Inline (Cache_Control); function Content_Disposition (Format : in String; Name : in String; Filename : in String) return String; pragma Inline (Content_Disposition); -- Note that this is not part of HTTP/1.1 standard, it is there because -- there is a lot of implementation around using it. This header is used -- in multipart data. function Host (Name : in String) return String; pragma Inline (Host); function Last_Modified (Date : in Calendar.Time) return String; pragma Inline (Last_Modified); function Location (URL : in String) return String; pragma Inline (Location); function Proxy_Authorization (Mode, Password : in String) return String; pragma Inline (Proxy_Authorization); function Proxy_Connection (Mode : in String) return String; pragma Inline (Proxy_Connection); function SOAPAction (URI : in String) return String; pragma Inline (SOAPAction); function Status_Line (Code : in Status_Code) return String; pragma Inline (Status_Line); function Transfer_Encoding (Encoding : in String) return String; pragma Inline (Transfer_Encoding); function User_Agent (Name : in String) return String; pragma Inline (User_Agent); function WWW_Authenticate (Realm : in String) return String; pragma Inline (WWW_Authenticate); -- Basic authentication request. function WWW_Authenticate (Realm : in String; Nonce : in String; Stale : in Boolean) return String; pragma Inline (WWW_Authenticate); -- Digest authentication request. ----------------------- -- helper functions - ----------------------- function Match (Str, Pattern : in String) return Boolean; pragma Inline (Match); -- Returns True if Pattern matches the begining of Str. The test is not -- case sensitive. function Does_Not_Match (Str, Pattern : in String) return Boolean; pragma Inline (Does_Not_Match); -- Returns True if Pattern does not matches the begining of Str. The test -- is not case sensitive. function To_HTTP_Date (Time : in Calendar.Time) return String; -- Returns an Ada time as a string using the HTTP normalized format. -- Format is RFC 822, updated by RFC 1123. function To_Time (HTTP_Date : in String) return Calendar.Time; -- Returns an Ada time from an HTTP one. This is To_HTTP_Date opposite -- function. private -- implementation removed end AWS.Messages; AWS.MIME ======== ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2000-2003 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: aws-mime.ads,v 1.13 2003/12/03 19:06:47 obry Exp $ package AWS.MIME is -- Some content type constants. All of them will be defined into this -- package and associated with the right extensions. It is possible to -- add new MIME types with the routines below or by placing a file named -- aws.mime into the startup directory. -- -- A MIME type is written in two parts: type/format ---------- -- Text - ---------- Text_CSS : constant String := "text/css"; Text_HTML : constant String := "text/html"; Text_Plain : constant String := "text/plain"; Text_XML : constant String := "text/xml"; Text_X_SGML : constant String := "text/x-sgml"; ----------- -- Image - ----------- Image_Gif : constant String := "image/gif"; Image_Jpeg : constant String := "image/jpeg"; Image_Png : constant String := "image/png"; Image_Tiff : constant String := "image/tiff"; Image_X_Portable_Anymap : constant String := "image/x-portable-anymap"; Image_X_Portable_Bitmap : constant String := "image/x-portable-bitmap"; Image_X_Portable_Graymap : constant String := "image/x-portable-graymap"; Image_X_Portable_Pixmap : constant String := "image/x-portable-pixmap"; Image_X_RGB : constant String := "image/x-rgb"; Image_X_Xbitmap : constant String := "image/x-xbitmap"; Image_X_Xpixmap : constant String := "image/x-xpixmap"; Image_X_Xwindowdump : constant String := "image/x-xwindowdump"; ----------------- -- Application - ----------------- Application_Postscript : constant String := "application/postscript"; Application_Pdf : constant String := "application/pdf"; Application_Zip : constant String := "application/zip"; Application_Octet_Stream : constant String := "application/octet-stream"; Application_Form_Data : constant String := "application/x-www-form-urlencoded"; Application_Mac_Binhex40 : constant String := "application/mac-binhex40"; Application_Msword : constant String := "application/msword"; Application_Powerpoint : constant String := "application/powerpoint"; Application_Rtf : constant String := "application/rtf"; Application_X_Compress : constant String := "application/x-compress"; Application_X_GTar : constant String := "application/x-gtar"; Application_X_GZip : constant String := "application/x-gzip"; Application_X_Latex : constant String := "application/x-latex"; Application_X_Sh : constant String := "application/x-sh"; Application_X_Shar : constant String := "application/x-shar"; Application_X_Tar : constant String := "application/x-tar"; Application_X_Tcl : constant String := "application/x-tcl"; Application_X_Tex : constant String := "application/x-tex"; Application_X_Texinfo : constant String := "application/x-texinfo"; Application_X_Troff : constant String := "application/x-troff"; Application_X_Troff_Man : constant String := "application/x-troff-man"; ----------- -- Audio - ----------- Audio_Basic : constant String := "audio/basic"; Audio_Mpeg : constant String := "audio/mpeg"; Audio_X_Wav : constant String := "audio/x-wav"; Audio_X_Pn_Realaudio : constant String := "audio/x-pn-realaudio"; Audio_X_Pn_Realaudio_Plugin : constant String := "audio/x-pn-realaudio-plugin"; Audio_X_Realaudio : constant String := "audio/x-realaudio"; ----------- -- Video - ----------- Video_Mpeg : constant String := "video/mpeg"; Video_Quicktime : constant String := "video/quicktime"; Video_X_Msvideo : constant String := "video/x-msvideo"; --------------- -- Multipart - --------------- Multipart_Form_Data : constant String := "multipart/form-data"; Multipart_X_Mixed_Replace : constant String := "multipart/x-mixed-replace"; ------------- -- Setting - ------------- procedure Add_Extension (Ext : in String; MIME_Type : in String); -- Add extension Ext (file extension without the dot, e.g. "txt") to the -- set of MIME type extension handled by this API. Ext will be mapped to -- the MIME_Type string. procedure Add_Regexp (Filename : in String; MIME_Type : in String); -- Add a specific rule to the MIME type table. Filename is a regular -- expression and will be mapped to the MIME_Type string. --------------- -- MIME Type - --------------- function Content_Type (Filename : in String) return String; -- Returns the MIME Content Type based on filename's extension or if not -- found the MIME Content type where Filename matches one of the specific -- rules set by Add_Regexp (see below). -- Returns "application/octet-stream" if the file type is unknown -- (i.e. no extension and no regular expression match filename). function Is_Text (MIME_Type : in String) return Boolean; -- Returns True if the MIME_Type is a text data function Is_Audio (MIME_Type : in String) return Boolean; -- Returns True if the MIME_Type is an audio data function Is_Image (MIME_Type : in String) return Boolean; -- Returns True if the MIME_Type is an image data function Is_Video (MIME_Type : in String) return Boolean; -- Returns True if the MIME_Type is a video data function Is_Application (MIME_Type : in String) return Boolean; -- Returns True if the MIME_Type is an application data end AWS.MIME; AWS.Net.SSL =========== ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2002-2004 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: aws-net-ssl.ads,v 1.11 2004/03/09 13:13:18 obry Exp $ -- This is the SSL based implementation of the Net package. The implementation -- should depend only on AWS.Net.Std and the SSL library. It is important to -- not call directly a socket binding here to ease porting. with Ada.Streams; with AWS.Net.Std; with SSL.Thin; package AWS.Net.SSL is use Ada.Streams; type Socket_Type is new Net.Std.Socket_Type with private; Is_Supported : constant Boolean; -- True if SSL supported in the current runtime ---------------- -- Initialize - ---------------- procedure Accept_Socket (Socket : in Net.Socket_Type'Class; New_Socket : in out Socket_Type); -- Accept a connection on a socket procedure Connect (Socket : in out Socket_Type; Host : in String; Port : in Positive); -- Connect a socket on a given host/port. If Security is true an secure -- socket will be used procedure Shutdown (Socket : in Socket_Type); -- Shutdown both side of the socket and close it procedure Free (Socket : in out Socket_Type); -- Release memory associated with the socket object -------- -- IO - -------- procedure Send (Socket : in Socket_Type; Data : in Stream_Element_Array); pragma Inline (Send); function Receive (Socket : in Socket_Type; Max : in Stream_Element_Count := 4096) return Stream_Element_Array; pragma Inline (Receive); -------------------- -- Initialization - -------------------- type Method is (SSLv2, SSLv2_Server, SSLv2_Client, SSLv23, SSLv23_Server, SSLv23_Client, TLSv1, TLSv1_Server, TLSv1_Client, SSLv3, SSLv3_Server, SSLv3_Client); type Config is private; Null_Config : constant Config; procedure Initialize (Config : in out SSL.Config; Certificate_Filename : in String; Security_Mode : in Method := SSLv23; Key_Filename : in String := ""; Exchange_Certificate : in Boolean := False); -- Initialize the SSL layer into Config. Certificate_Filename must point -- to a valid certificate. Security mode can be used to change the -- security method used by AWS. Key_Filename must be specified if the key -- is not in the same file as the certificate. The Config object can be -- associated with all secure sockets sharing the same options. If -- Exchange_Certificate is True the client will send it's certificate to -- the server, if False only the server will send its certificate. procedure Release (Config : in out SSL.Config); -- Release memory associated with the Config object procedure Set_Config (Socket : in out Socket_Type; Config : in SSL.Config); -- Set the SSL configuration object for the secure socket private -- implementation removed end AWS.Net.SSL; AWS.Net.SSL.Certificate ======================= ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2003 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: aws-net-ssl-certificate.ads,v 1.1 2003/12/17 14:37:18 obry Exp $ with Ada.Strings.Unbounded; package AWS.Net.SSL.Certificate is use Ada.Strings.Unbounded; type Object is private; Undefined : constant Object; function Get (Socket : in Socket_Type) return Object; -- Returns the certificate used by the SSL function Subject (Certificate : in Object) return String; -- Returns the certificate's subject function Issuer (Certificate : in Object) return String; -- Returns the certificate's issuer private -- implementation removed end AWS.Net.SSL.Certificate; AWS.Parameters ============== ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2000-2002 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: aws-parameters.ads,v 1.16 2003/02/02 12:04:49 obry Exp $ with Ada.Strings.Unbounded; with AWS.Containers.Tables; package AWS.Parameters is type List is new AWS.Containers.Tables.Table_Type with private; subtype VString_Array is AWS.Containers.Tables.VString_Array; function URI_Format (Parameter_List : in List) return String; -- Returns the list of parameters in the URI format. This can be added -- after the ressource to form the complete URI. The format is: -- "?name1=value1&name2=value2..." -- See AWS.Containers.Tables for inherited routines. private -- implementation removed end AWS.Parameters; AWS.POP ======= ------------------------------------------------------------------------------ -- Ada Web Server - -- P O P - Post Office Protocol - -- - -- Copyright (C) 2003-2004 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: aws-pop.ads,v 1.8 2004/02/08 20:57:51 obry Exp $ with Ada.Finalization; with Ada.Strings.Unbounded; with AWS.Headers; with AWS.Net.Std; with AWS.Resources.Streams; package AWS.POP is use Ada.Strings.Unbounded; POP_Error : exception; -- Raised by all routines when an error has been detected ------------- -- Mailbox - ------------- Default_POP_Port : constant := 110; type Mailbox is private; type Authenticate_Mode is (Clear_Text, APOP); function Initialize (Server_Name : in String; User : in String; Password : in String; Authenticate : in Authenticate_Mode := Clear_Text; Port : in Positive := Default_POP_Port) return Mailbox; -- Connect on the given Port to Server_Name and open User's Mailbox. This -- mailbox object will be used to retrieve messages. procedure Close (Mailbox : in POP.Mailbox); -- Close mailbox function User_Name (Mailbox : in POP.Mailbox) return String; -- Returns User's name for this mailbox function Message_Count (Mailbox : in POP.Mailbox) return Natural; -- Returns the number of messages in the user's mailbox function Size (Mailbox : in POP.Mailbox) return Natural; -- Returns the total size in bytes of the user's mailbox ------------- -- Message - ------------- type Message is tagged private; function Get (Mailbox : in POP.Mailbox; N : in Positive; Remove : in Boolean := False) return Message; -- Retrieve Nth message from the mailbox, let the message on the mailbox -- if Remove is False. procedure Delete (Mailbox : in POP.Mailbox; N : in Positive); -- Detele message number N from the mailbox function Get_Header (Mailbox : in POP.Mailbox; N : in Positive) return Message; -- Retrieve headers for the Nth message from the mailbox, let the message -- on the mailbox. This is useful to build a quick summary of the mailbox. generic with procedure Action (Message : in POP.Message; Index : in Positive; Quit : in out Boolean); procedure For_Every_Message (Mailbox : in POP.Mailbox; Remove : in Boolean := False); -- Calls Action for each message read on the mailbox, delete the message -- from the mailbox if Remove is True. Set Quit to True to stop the -- iterator. Index is the mailbox's message index. generic with procedure Action (Message : in POP.Message; Index : in Positive; Quit : in out Boolean); procedure For_Every_Message_Header (Mailbox : in POP.Mailbox); -- Calls Action for each message read on the mailbox. Only the headers are -- read from the mailbox. Set Quit to True to stop the iterator. Index is -- the mailbox's message index. function Size (Message : in POP.Message) return Natural; -- Returns the message size in bytes function Content (Message : in POP.Message) return Unbounded_String; -- Returns message's content as an Unbounded_String. Each line are -- separated by CR+LF characters. function From (Message : in POP.Message) return String; -- Returns From header value function CC (Message : in POP.Message; N : Natural := 0) return String; -- Retruns the CC header value. If N = 0 returns all recipients separated -- by a coma otherwise it returns the Nth CC recipient. function CC_Count (Message : in POP.Message) return Natural; -- Returns the number of CC recipient for Message. Returns 0 if there is -- no CC for this message. function Subject (Message : in POP.Message) return String; -- Returns Subject header value function Date (Message : in POP.Message) return String; -- Returns Date header value function Header (Message : in POP.Message; Header : in String) return String; -- Returns header value for header named Header, returns the empty string -- if such header does not exist. ---------------- -- Attachment - ---------------- type Attachment is private; function Attachment_Count (Message : in POP.Message) return Natural; -- Returns the number of Attachments into Message function Get (Message : in POP.Message'Class; Attachment : in Positive) return Attachment; -- Returns the Nth Attachment for Message, Raises Constraint_Error if -- there is not such attachment. generic with procedure Action (Attachment : in POP.Attachment; Index : in Positive; Quit : in out Boolean); procedure For_Every_Attachment (Message : in POP.Message); -- Calls action for every Attachment in Message. Stop iterator if Quit is -- set to True, Quit is set to False by default. function Content (Attachment : in POP.Attachment) return AWS.Resources.Streams.Stream_Access; -- Returns Attachment's content as a memory stream. Note that the stream -- has already been decoded. Most attachments are MIME Base64 encoded. function Content (Attachment : in POP.Attachment) return Unbounded_String; -- Returns Attachment's content as an Unbounded_String. This routine must -- only be used for non file attachments. Raises Constraint_Error if -- called for a file attachment. function Filename (Attachment : in POP.Attachment) return String; -- Returns the Attachment filename or the empty string if it is not a file -- but an embedded message. function Is_File (Attachment : in POP.Attachment) return Boolean; -- Returns True if Attachment is a file procedure Write (Attachment : in POP.Attachment; Directory : in String); -- Writes Attachment's file content into Directory. This must only be used -- for a file attachment. private -- implementation removed end AWS.POP; AWS.Resources ============= ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2002-2003 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: aws-resources.ads,v 1.19 2004/02/02 16:54:50 anisimko Exp $ with Ada.Calendar; with Ada.Streams; with Ada.Unchecked_Deallocation; package AWS.Resources is use Ada.Streams; Resource_Error : exception; type File_Type is limited private; type File_Instance is (None, Plain, GZip, Both); -- None : No instance of this file present. -- Plain : A non-compressed version of this file exists. -- GZip : A gzip encoded version of this file exists. -- Both : Both versions of this file exists. subtype Content_Length_Type is Stream_Element_Offset; Undefined_Length : constant Content_Length_Type; -- Undefined length could be used when we do not know the message stream -- length at the start of transfer. The end of message could be determined -- by the chunked transfer-encoding in the HTTP/1.1, or by the closing -- connection in the HTTP/1.0. procedure Open (File : out File_Type; Name : in String; Form : in String := ""); -- Open file in mode In_File. Only reading from the file is supported. -- This procedure open the in-memory (embedded) file if present, otherwise -- the file on disk is opened. Note that if Name file is not found, it -- checks for Name & ".gz" and unzipped the file content in this case. procedure Open (File : out File_Type; Name : in String; Form : in String := ""; GZip : in out Boolean); -- Open file in mode In_File. Only reading from the file is supported. -- This procedure open the in-memory (embedded) file if present, otherwise -- the file on disk is opened. If GZip parameter is False this call is -- equivalent to the Open routine above. If GZip is True this routine will -- first check for the compressed version of the resource (Name & ".gz"), -- if found GZip output value will remain True. If GZip value is True and -- the compressed version of the resource does not exist it looks for -- non-compressed version and set GZip value to False. procedure Reset (Resource : in out File_Type); -- Reset the file, reading will restart at the beginning procedure Close (Resource : in out File_Type); -- Close the file procedure Read (Resource : in out File_Type; Buffer : out Stream_Element_Array; Last : out Stream_Element_Offset); -- Returns a set of bytes from the file procedure Get_Line (Resource : in out File_Type; Buffer : out String; Last : out Natural); -- Returns a line from the file. A line is a set of character terminated -- by ASCII.LF (UNIX style EOF) or ASCII.CR+ASCII.LF (DOS style EOF). function End_Of_File (Resource : in File_Type) return Boolean; -- Returns true if there is no more data to read. function LF_Terminated (Resource : in File_Type) return Boolean; -- Returns True if last line returned by Get_Line was terminated with a LF -- or CR+LF on DOS based systems. function Size (Resource : in File_Type) return Content_Length_Type; -- Returns the size (in bytes) of the resource. If the size of the -- resource is not defined, the routine Size returns Undefined_Length -- value. function Exist (Name : in String) return File_Instance; -- Return GZip if only file Name & ".gz" exists. -- Return Plain if only file Name exists. -- Return Both if both file Name and Name & ".gz" exists. -- Return None if files neither Name nor Name & ".gz" exist. function Is_Regular_File (Name : in String) return Boolean; -- Returns True if Filename is a regular file and is readable. Checks -- first for in memory file then for disk file. function File_Size (Name : in String) return Stream_Element_Offset; -- Returns Filename's size in bytes. Checks first for in memory file -- then for disk file. function File_Timestamp (Name : in String) return Ada.Calendar.Time; -- Get the time for last modification to a file in UTC/GMT. Checks first -- for in memory file then for disk file. private -- implementation removed end AWS.Resources; AWS.Resources.Embedded ====================== ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2002-2003 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: aws-resources-embedded.ads,v 1.15 2004/02/02 16:54:50 anisimko Exp $ with Ada.Streams; with AWS.Resources.Streams.Memory; package AWS.Resources.Embedded is use Ada; subtype Buffer_Access is Streams.Memory.Buffer_Access; procedure Open (File : out File_Type; Name : in String; Form : in String := ""; GZip : in out Boolean); -- Open resource from registered data procedure Create (File : out File_Type; Buffer : in Buffer_Access); -- Create the resource directly from memory data function Exist (Name : in String) return File_Instance; -- Return GZip if only file Name & ".gz" exists. -- Return Plain if only file Name exists. -- Return Both if both file Name and Name & ".gz" exists. -- Return None if files neither Name nor Name & ".gz" exist. function Is_Regular_File (Name : in String) return Boolean; pragma Inline (Is_Regular_File); -- Returns True if file named Name has been registered (i.e. it is an -- in-memory file). function File_Size (Name : in String) return Ada.Streams.Stream_Element_Offset; function File_Timestamp (Name : in String) return Ada.Calendar.Time; procedure Register (Name : in String; Content : in Buffer_Access; File_Time : in Calendar.Time); -- Register a new file named Name into the embedded resources. The file -- content is pointed to by Content, the File_Time must be the last -- modification time stamp for the file. If Name ends with ".gz" the -- embedded resource registered as compressed. end AWS.Resources.Embedded; AWS.Resources.Files =================== ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2002-2003 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: aws-resources-files.ads,v 1.11 2004/02/02 16:54:50 anisimko Exp $ package AWS.Resources.Files is procedure Open (File : out File_Type; Name : in String; Form : in String := ""; GZip : in out Boolean); procedure Open (File : out File_Type; Name : in String; Form : in String := ""); function Exist (Name : in String) return File_Instance; -- Return GZip if only file Name & ".gz" exists. -- Return Plain if only file Name exists. -- Return Both if both file Name and Name & ".gz" exists. -- Return None if files neither Name nor Name & ".gz" exist. function Is_Regular_File (Name : in String) return Boolean; function File_Size (Name : in String) return Ada.Streams.Stream_Element_Offset; function File_Timestamp (Name : in String) return Ada.Calendar.Time; end AWS.Resources.Files; AWS.Resources.Streams ===================== ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2002-2003 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: aws-resources-streams.ads,v 1.10 2003/11/12 22:51:55 obry Exp $ package AWS.Resources.Streams is use Ada; type Stream_Type is abstract tagged limited private; type Stream_Access is access all Stream_Type'Class; function End_Of_File (Resource : in Stream_Type) return Boolean is abstract; procedure Read (Resource : in out Stream_Type; Buffer : out Stream_Element_Array; Last : out Stream_Element_Offset) is abstract; procedure Reset (Resource : in out Stream_Type) is abstract; procedure Close (Resource : in out Stream_Type) is abstract; function Size (Resource : in Stream_Type) return Stream_Element_Offset; -- This default implementation returns Undefined_Length. If the derived -- stream implementation knows about the size (in bytes) of the stream -- this routine should be redefined. procedure Create (Resource : out File_Type; Stream : in Stream_Access); pragma Inline (Create); -- Create a resource file from user defined stream private -- implementation removed end AWS.Resources.Streams; AWS.Resources.Streams.Memory ============================ ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2003 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $RCSfile: aws-resources-streams-memory.ads,v $ -- $Revision: 1.12 $ -- $Date: 2003/12/19 04:51:38 $ -- $Author: anisimko $ -- API to handle a memory stream. A memory stream is first created -- empty. User can add chunk of data using the Append routines. The stream -- is then read using the Read procedure. with AWS.Utils; with Memory_Streams; package AWS.Resources.Streams.Memory is use Ada; type Stream_Type is new Streams.Stream_Type with private; subtype Stream_Element_Access is Utils.Stream_Element_Array_Access; type Buffer_Access is access constant Ada.Streams.Stream_Element_Array; procedure Append (Resource : in out Stream_Type; Buffer : in Stream_Element_Array; Trim : in Boolean := False); -- Append Buffer into the memory stream procedure Append (Resource : in out Stream_Type; Buffer : in Stream_Element_Access); -- Append static data pointed to Buffer into the memory stream as is. -- The stream will free the memory on close. procedure Append (Resource : in out Stream_Type; Buffer : in Buffer_Access); -- Append static data pointed to Buffer into the memory stream as is. -- The stream would not try to free the memory on close. procedure Read (Resource : in out Stream_Type; Buffer : out Stream_Element_Array; Last : out Stream_Element_Offset); -- Returns a chunck of data in Buffer, Last point to the last element -- returned in Buffer. function End_Of_File (Resource : in Stream_Type) return Boolean; -- Returns True if the end of the memory stream has been reached procedure Clear (Resource : in out Stream_Type); pragma Inline (Clear); -- Delete all data from memory stream procedure Reset (Resource : in out Stream_Type); -- Reset the streaming data to the first position function Size (Resource : in Stream_Type) return Stream_Element_Offset; -- Returns the number of bytes in the memory stream procedure Close (Resource : in out Stream_Type); -- Close the memory stream. Release all memory associated with the stream private -- implementation removed end AWS.Resources.Streams.Memory; AWS.Resources.Streams.Memory.ZLib ================================= ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2003 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $RCSfile: aws-resources-streams-memory-zlib.ads,v $ -- $Revision: 1.14 $ -- $Date: 2003/12/19 04:50:24 $ -- $Author: anisimko $ -- This API is used as for standard memory stream (see parent package), the -- only difference is that the stream is compressed. with ZLib; package AWS.Resources.Streams.Memory.ZLib is package ZL renames Standard.ZLib; type Stream_Type is new Memory.Stream_Type with private; subtype Window_Bits_Type is ZL.Window_Bits_Type; subtype Header_Type is ZL.Header_Type; subtype Compression_Level is ZL.Compression_Level; subtype Strategy_Type is ZL.Strategy_Type; subtype Compression_Method is ZL.Compression_Method; subtype Memory_Level_Type is ZL.Memory_Level_Type; Default_Compression : constant Compression_Level := ZL.Default_Compression; Default_Header : constant Header_Type := ZL.Default; procedure Deflate_Initialize (Resource : in out Stream_Type; Level : in Compression_Level := ZL.Default_Compression; Strategy : in Strategy_Type := ZL.Default_Strategy; Method : in Compression_Method := ZL.Deflated; Window_Bits : in Window_Bits_Type := ZL.Default_Window_Bits; Memory_Level : in Memory_Level_Type := ZL.Default_Memory_Level; Header : in Header_Type := ZL.Default); pragma Inline (Deflate_Initialize); -- Initialize the compression procedure Inflate_Initialize (Resource : in out Stream_Type; Window_Bits : in Window_Bits_Type := ZL.Default_Window_Bits; Header : in Header_Type := ZL.Default); pragma Inline (Inflate_Initialize); -- Initialize the decompression procedure Append (Resource : in out Stream_Type; Buffer : in Stream_Element_Array; Trim : in Boolean := False); -- Compress and Append Buffer into the memory stream procedure Read (Resource : in out Stream_Type; Buffer : out Stream_Element_Array; Last : out Stream_Element_Offset); -- Returns a chunck of data in Buffer, Last point to the last element -- returned in Buffer. function Size (Resource : in Stream_Type) return Stream_Element_Offset; -- Returns the number of bytes in the memory stream procedure Close (Resource : in out Stream_Type); -- Close the ZLib stream, release all memory associated with the Resource -- object. private -- implementation removed end AWS.Resources.Streams.Memory.ZLib; AWS.Response ============ ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2000-2004 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: aws-response.ads,v 1.62 2004/03/19 17:09:52 anisimko Exp $ -- This package is to be used to build answer to be sent to the client -- browser. It is also used as the object returned from the client API. So -- it is either a response built on the server side or the response received -- on the client side. with Ada.Strings.Unbounded; with Ada.Streams; with Ada.Finalization; with Ada.Unchecked_Deallocation; with AWS.Headers; with AWS.Messages; with AWS.MIME; with AWS.Net; with AWS.Resources.Streams; with AWS.Status; package AWS.Response is use Ada; type Data is private; -- Note that this type use a reference counter which is not thread safe. type Callback is access function (Request : in Status.Data) return Data; -- This is the Web Server Callback procedure. A client must declare and -- pass such procedure to the HTTP record. type Data_Mode is (Header, -- Send only the HTTP header Message, -- Send a standard HTTP message File, -- Send a file File_Once, -- Send a file once, delete it after sending Stream, -- Send a stream Socket_Taken, -- Socket has been taken from the server No_Data); -- No data, this is not a response type Authentication_Mode is (Any, Basic, Digest); -- The authentication mode. -- "Basic" and "Digest" mean that server must accept the requested -- authentication mode. "Any" mean that server could accept any -- authentication from client. -- Note the order here should not be changed as it is used in AWS.Client. subtype Content_Length_Type is Integer range -1 .. Integer'Last; Undefined_Length : constant Content_Length_Type; -- Undefined length could be used when we do not know the message length -- at the start of transfer. The end of message could be determined by the -- chunked transfer-encoding in the HTTP/1.1, or by the closing connection -- in the HTTP/1.0. Default_Moved_Message : constant String; -- This is a template message, _@_ will be replaced by the Location (see -- function Build with Location below). Default_Authenticate_Message : constant String; -- This is the message that will be displayed on the Web Browser if the -- authentication process fails or is cancelled. ----------------------- -- Data Constructors - ----------------------- function Build (Content_Type : in String; Message_Body : in String; Status_Code : in Messages.Status_Code := Messages.S200; Cache_Control : in Messages.Cache_Option := Messages.Unspecified; Encoding : in Messages.Content_Encoding := Messages.Identity) return Data; function Build (Content_Type : in String; UString_Message : in Strings.Unbounded.Unbounded_String; Status_Code : in Messages.Status_Code := Messages.S200; Cache_Control : in Messages.Cache_Option := Messages.Unspecified; Encoding : in Messages.Content_Encoding := Messages.Identity) return Data; -- Return a message whose body is passed into Message_Body. The -- Content_Type parameter is the MIME type for the message -- body. Status_Code is the response status (see Messages.Status_Code -- definition). function Build (Content_Type : in String; Message_Body : in Streams.Stream_Element_Array; Status_Code : in Messages.Status_Code := Messages.S200; Cache_Control : in Messages.Cache_Option := Messages.Unspecified; Encoding : in Messages.Content_Encoding := Messages.Identity) return Data; -- Idem above, but the message body is a stream element array function File (Content_Type : in String; Filename : in String; Status_Code : in Messages.Status_Code := Messages.S200; Cache_Control : in Messages.Cache_Option := Messages.Unspecified; Encoding : in Messages.Content_Encoding := Messages.Identity; Once : in Boolean := False) return Data; -- Returns a message whose message body is the content of the file. The -- Content_Type must indicate the MIME type for the file. function Stream (Content_Type : in String; Handle : access Resources.Streams.Stream_Type'Class; Status_Code : in Messages.Status_Code := Messages.S200; Cache_Control : in Messages.Cache_Option := Messages.No_Cache; Encoding : in Messages.Content_Encoding := Messages.Identity; Server_Close : in Boolean := True) return Data; -- Returns a message whose message body is the content of the user -- defined stream. The Content_Type must indicate the MIME type for -- the data stream, Stream_Size the total number of bytes and Status_Code -- the header status code which should be send back to client's browser. -- If Server_Close is set to False the server will not close the stream -- after sending it, it is then user's responsability to close the stream. ------------------------------ -- Redirection Constructors - ------------------------------ function URL (Location : in String) return Data; -- This ask the server for a redirection to the specified URL function Moved (Location : in String; Message : in String := Default_Moved_Message) return Data; -- This send back a moved message (Messages.S301) with the specified -- message body. ------------------------ -- Other Constructors - ------------------------ function Acknowledge (Status_Code : in Messages.Status_Code; Message_Body : in String := ""; Content_Type : in String := MIME.Text_HTML) return Data; -- Returns a message to the Web browser. This routine must be used to -- send back an error message to the Web browser. For example if a -- requested resource cannot be served a message with status code S404 -- must be sent. function Authenticate (Realm : in String; Mode : in Authentication_Mode := Basic; Stale : in Boolean := False; Message : in String := Default_Authenticate_Message) return Data; -- Returns an authentification message (Messages.S401), the Web browser -- will then ask for an authentification. Realm string will be displayed -- by the Web Browser in the authentification dialog box. function Socket_Taken return Data; -- Must be used to say that the connection socket has been taken by user -- inside of user callback. No operations should be performed on this -- socket, and associated slot should be released for further operations. function Empty return Data; -- Returns an empty message (Data_Mode = No_Data and Status_Code is 204). -- It is used to say that user's handlers were not able to do something -- with the request. This is used by the callback's chain in the -- dispatcher and should not be used by users. -- -- API to retrieve response data -- ------------ -- Header - ------------ function Header (D : in Data; Name : in String; N : in Positive) return String; pragma Inline (Header); -- Return the N-th value for header Name function Header (D : in Data; Name : in String) return String; pragma Inline (Header); -- Return all values as a comma-separated string for header Name. -- See [RFC 2616 - 4.2] last paragraph. procedure Send_Header (Socket : in Net.Socket_Type'Class; D : in Data); pragma Inline (Send_Header); -- Send all header lines to the socket function Status_Code (D : in Data) return Messages.Status_Code; pragma Inline (Status_Code); -- Returns the status code function Content_Length (D : in Data) return Content_Length_Type; pragma Inline (Content_Length); -- Returns the content length (i.e. the message body length). A value of 0 -- indicate that there is no message body. function Content_Type (D : in Data) return String; pragma Inline (Content_Type); -- Returns the MIME type for the message body function Cache_Control (D : in Data) return Messages.Cache_Option; pragma Inline (Cache_Control); -- Returns the cache control specified for the response function Location (D : in Data) return String; pragma Inline (Location); -- Returns the location for the new page in the case of a moved -- message. See Moved constructor above. ---------- -- Data - ---------- function Mode (D : in Data) return Data_Mode; pragma Inline (Mode); -- Returns the data mode, either Header, Message or File function Message_Body (D : in Data) return String; pragma Inline (Message_Body); -- Returns the message body content as a string. -- Message_Body routines could not be used with user defined streams -- (see. Stream routine in this package). Constraint_Error would be raised -- on try to get data by the Message_Body from the user defined streams. -- For get data from user defined streams routine Create_Resource should -- be used. function Message_Body (D : in Data) return Strings.Unbounded.Unbounded_String; -- Returns message body content as an unbounded_string function Message_Body (D : in Data) return Streams.Stream_Element_Array; -- Returns message body as a binary content procedure Message_Body (D : in Data; File : out AWS.Resources.File_Type); -- Returns the message body as a stream function Filename (D : in Data) return String; pragma Inline (Filename); -- Returns the filename which should be sent back -------------------- -- Authentication - -------------------- function Realm (D : in Data) return String; pragma Inline (Realm); -- Returns the Realm for the current authentification request function Authentication (D : in Data) return Authentication_Mode; pragma Inline (Authentication); -- Returns the authentication mode requested by server function Authentication_Stale (D : in Data) return Boolean; pragma Inline (Authentication_Stale); -- Returns the stale parameter for authentication --------------- -- Resources - --------------- procedure Create_Resource (D : in out Data; File : out AWS.Resources.File_Type; GZip : in Boolean); pragma Inline (Create_Resource); -- Creates the resource object (either a file or in-memory object) for -- the data to be sent to the client. The resource should be closed after -- use. -- GZip is true when the http client support GZip decoding, -- if file or embedded resource is in the GZip format this routine would -- define Content-Encoding header field value. function Close_Resource (D : in Data) return Boolean; -- Returns True if the resource stream must be close private -- implementation removed end AWS.Response; AWS.Server ========== ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2000-2003 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: aws-server.ads,v 1.84 2004/01/06 12:53:36 anisimko Exp $ with Ada.Calendar; with Ada.Exceptions; with Ada.Finalization; with AWS.Config; with AWS.Default; with AWS.Dispatchers; with AWS.Exceptions; with AWS.Hotplug; with AWS.Log; with AWS.Net.Std; with AWS.Net.SSL; with AWS.Response; with AWS.Utils; package AWS.Server is type HTTP is limited private; -- A Web server. --------------------------- -- Server initialization - --------------------------- -- Note that starting a sercure server if AWS has not been configured to -- support HTTPS will raise Program_Error. procedure Start (Web_Server : in out HTTP; Callback : in Response.Callback; Config : in AWS.Config.Object); -- Start server using a full configuration object. With this routine it is -- possible to control all features of the server. A simplified version of -- Start is also provided below with the most common options. -- User_Config_Filename is a specific configuration file that will parsed -- after 'aws.ini', 'prognam.ini', '.ini' files. procedure Start (Web_Server : in out HTTP; Dispatcher : in Dispatchers.Handler'Class; Config : in AWS.Config.Object); -- Idem, but using the dispatcher tagged type instead of callback. See -- AWS.Services.Dispatchers and AWS.Dispatchers hierarchies for built-in -- services and interface to build your own dispatcher models. -- Note that a copy of the Dispatcher is keept into Web_Server. Any -- changes done to the Dispatcher object will not be part of the Web -- server dispatcher. procedure Start (Web_Server : in out HTTP; Name : in String; Callback : in Response.Callback; Max_Connection : in Positive := Default.Max_Connection; Admin_URI : in String := Default.Admin_URI; Port : in Positive := Default.Server_Port; Security : in Boolean := False; Session : in Boolean := False; Case_Sensitive_Parameters : in Boolean := True; Upload_Directory : in String := Default.Upload_Directory; Line_Stack_Size : in Positive := Default.Line_Stack_Size); -- Start the Web server. Max_Connection is the number of simultaneous -- connections the server's will handle (the number of slots in AWS). -- Name is just a string used to identify the server. This is used -- for example in the administrative page. Admin_URI must be set to enable -- the administrative status page. Callback is the procedure to call for -- each resource requested. Port is the Web server port. If Security is -- set to True the server will use an HTTPS/SSL connection. If Session is -- set to True the server will be able to get a status for each client -- connected. A session ID is used for that, on the client side it is a -- cookie. Case_Sensitive_Parameters if set to False it means that the CGI -- parameters name will be handled without case sensitivity. Upload -- directory point to a directory where uploaded files will be stored. ------------------------ -- Server termination - ------------------------ procedure Shutdown (Web_Server : in out HTTP); -- Stop the server and release all associated memory. This routine can -- take some time to terminate because it waits for all tasks to terminate -- properly before releasing the memory. The log facilities will be -- automatically stopped by calling Stop_Log below. type Termination is (No_Server, Q_Key_Pressed, Forever); procedure Wait (Mode : in Termination := No_Server); -- The purpose of this procedure is to control the main procedure -- termination. This procedure will return only when no server are running -- (No_Server mode) or the 'q' key has been pressed. If mode is set to -- Forever, Wait will never return and the process will have to be killed. -------------------------- -- Server configuration - -------------------------- function Config (Web_Server : in HTTP) return AWS.Config.Object; -- Returns configuration object for Web_Server procedure Set_Unexpected_Exception_Handler (Web_Server : in out HTTP; Handler : in Exceptions.Unexpected_Exception_Handler); -- Set the unexpected exception handler. It is called whenever an -- unrecoverable error has been detected. The default handler just display -- (on standard output) an error message with the location of the -- error. By changing this handler it is possible to log or display full -- symbolic stack backtrace if needed. procedure Set (Web_Server : in out HTTP; Dispatcher : in Dispatchers.Handler'Class); -- Dynamically associate a new dispatcher object to the server. With the -- feature it is possible to change server behavior at runtime. The -- complete set of callback procedures will be changed when calling this -- routine. procedure Set_Security (Web_Server : in out HTTP; Certificate_Filename : in String; Security_Mode : in Net.SSL.Method := Net.SSL.SSLv23_Server; Key_Filename : in String := ""); -- Set security option for AWS. Certificate_Filename is the name of a file -- containing a certificate. Key_Filename is the name of the file -- containing the key, if the empty string the key will be taken from the -- certificate filename. This must be called before starting the secure -- server otherwise the default security options or options set in the -- config files will be used. After that the call will have no effect. type HTTP_Access is access all HTTP; function Get_Current return HTTP_Access; -- Get current server. This can be used in a callback procedure to -- retrieve the running HTTP server. It is needed when a callback -- procedure is shared by multiple servers. --------------- -- Other API - --------------- procedure Give_Back_Socket (Web_Server : in out HTTP; Socket : in Net.Socket_Type'Class); -- Give the socket back to the server. Socket must have been taken from -- the server using the Response.Socket_Taken routine in a callback. private -- implementation removed end AWS.Server; AWS.Server.Hotplug ================== ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2000-2003 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: aws-server-hotplug.ads,v 1.6 2003/12/03 11:14:25 obry Exp $ package AWS.Server.Hotplug is Register_Message : constant String := "REGISTER"; Unregister_Message : constant String := "UNREGISTER"; procedure Activate (Web_Server : in HTTP_Access; Port : in Positive); -- Start hotplug server listening at the specified Port for the Web_Server end AWS.Server.Hotplug; AWS.Server.Log ============== ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2003 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: aws-server-log.ads,v 1.1 2003/10/10 12:54:14 obry Exp $ package AWS.Server.Log is ------------------ -- Standard Log - ------------------ procedure Start (Web_Server : in out HTTP; Split_Mode : in AWS.Log.Split_Mode := AWS.Log.None; Filename_Prefix : in String := ""; Auto_Flush : in Boolean := False); -- Activate server's logging activity. See AWS.Log. If Auto_Flush is True -- the file will be flushed after all written data. function Name (Web_Server : in HTTP) return String; -- Return the name of the Log or an empty string if one is not active procedure Stop (Web_Server : in out HTTP); -- Stop server's logging activity. See AWS.Log function Is_Active (Web_Server : in HTTP) return Boolean; -- Returns True if the Web Server log has been activated procedure Flush (Web_Server : in out HTTP); -- Flush the server log. -- Note that error log does not need to be flushed because it is always -- flushed by default. --------------- -- Error Log - --------------- procedure Start_Error (Web_Server : in out HTTP; Split_Mode : in AWS.Log.Split_Mode := AWS.Log.None; Filename_Prefix : in String := ""); -- Activate server's logging activity. See AWS.Log function Error_Name (Web_Server : in HTTP) return String; -- Return the name of the Error Log or an empty string if one is not active procedure Stop_Error (Web_Server : in out HTTP); -- Stop server's logging activity. See AWS.Log function Is_Error_Active (Web_Server : in HTTP) return Boolean; -- Returns True if the Web Server error log has been activated end AWS.Server.Log; AWS.Server.Push =============== ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2000-2003 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: aws-server-push.ads,v 1.15 2003/10/29 09:32:48 obry Exp $ -- Package to support Server Push feature. This is only supported by Netscape -- browsers. It will not work with Microsoft Internet Explorer. -- For Microsoft Internet Explorer complementary active components -- should be used like java applets or ActiveX controls. with AWS.Net.Stream_IO; with Table_Of_Strings_And_Static_Values_G; generic type Client_Output_Type (<>) is private; -- Data type client want to send through server push. type Stream_Output_Type (<>) is private; -- Data type to be sent through the socket stream. type Client_Environment is private; -- Data type to keep client context. This context will be passed to the -- conversion routine below. with function To_Stream_Output (Output : in Client_Output_Type; Client : in Client_Environment) return Stream_Output_Type; -- Function used for convert Client_Output_Type to Stream_Output_Type. -- This is used by the server to prepare the data to be sent to the -- clients. package AWS.Server.Push is Client_Gone : exception; -- Raised when a client is not responding. Closed : exception; -- Raised when trying to register to a closed push server. Duplicate_Client_ID : exception; -- Raised in trying to register an already registered client. type Object is limited private; -- This is the push server object. A push server has two modes, either it -- is Open or Closed. When open it will send data to registered -- clients. No data will be sent to registered client if the server is -- Closed. type Mode is (Plain, Multipart, Chunked); -- Describeed the mode to communicate with the client. -- Plain : no transformation is done, the data are sent as-is -- Multipart : data are MIME encoded. -- Chuncked : data are chunked, a piece of data is sent in small pieces. subtype Client_Key is String; -- The Client ID key representation. In a server each client must have a -- uniq ID. This ID is used for registration and for sending data to -- specific client. procedure Register (Server : in out Object; Client_ID : in Client_Key; Socket : in Net.Socket_Type'Class; Environment : in Client_Environment; Init_Data : in Client_Output_Type; Init_Content_Type : in String := ""; Kind : in Mode := Plain; Close_Duplicate : in Boolean := False); -- Add client identified by Client_ID to the server subscription -- list and send the Init_Data (as a Data_Content_Type mime content) to -- him. After registering this client will be able to receive pushed data -- from the server in brodcasting mode. If Close_Duplicate is True and -- Client_ID is already registered into the list then old one will be -- unregistered first (no exception will be raised). procedure Register (Server : in out Object; Client_ID : in Client_Key; Socket : in Net.Socket_Type'Class; Environment : in Client_Environment; Kind : in Mode := Plain; Close_Duplicate : in Boolean := False); -- Same as above but without sending initial data. procedure Unregister (Server : in out Object; Client_ID : in Client_Key; Close_Socket : in Boolean := True); -- Removes client Client_ID from server subscription list. The associated -- client's socket will be closed if Close_Socket is True. No exception is -- raised if Client_ID was not registered. procedure Unregister_Clients (Server : in out Object; Close_Sockets : in Boolean := True); -- Remove all registered clients from the server. Closes if Close_Sockets -- is set to True (default) otherwise the sockets remain open. After this -- call the sever will still in running mode. Does nothing if there is no -- client registered. procedure Send_To (Server : in out Object; Client_ID : in Client_Key; Data : in Client_Output_Type; Content_Type : in String := ""); -- Push data to a specified client identified by Client_ID. procedure Send (Server : in out Object; Data : in Client_Output_Type; Content_Type : in String := ""); -- Push data to every client (broadcast) subscribed to the server. generic with procedure Client_Gone (Client_ID : in String); procedure Send_G (Server : in out Object; Data : in Client_Output_Type; Content_Type : in String := ""); -- Push data to every client (broadcast) subscribed to the server. -- Call Client_Gone for each client with broken socket. function Count (Server : in Object) return Natural; -- Returns the number of registered clients in the server. function Is_Open (Server : in Object) return Boolean; -- Return True if the server is open, meaning server is still running, -- ready to accept client's registration and still sending data to -- clients. -- Shutdown routines put the server in a Closed mode. The routines below -- provides a way to eventually close the socket, to send some -- finalisation data. procedure Shutdown (Server : in out Object; Close_Sockets : in Boolean := True); -- Unregisted all clients and close all associated connections (socket) if -- Close_Socket is True. The server will be in Closed mode. After this -- call any client trying to register will get the Closed exception. It is -- possible to reactivate the server with Restart. procedure Shutdown (Server : in out Object; Final_Data : in Client_Output_Type; Final_Content_Type : in String := ""); -- Idem as above but it send Final_Data (as a Data_Content_Type mime -- content) before closing connections. procedure Shutdown_If_Empty (Server : in out Object; Open : out Boolean); -- Server will be shutdown (close mode) if there is no more active clients -- (Count = 0). Returns new server status in Open (Open will be True if -- server is in Open mode and False otherwise). After this call any client -- trying to register will get the Closed exception. It is possible to -- reactivate the server with Restart. procedure Restart (Server : in out Object); -- Set server to Open mode. Server will again send data to registered -- clients. It does nothing if server was already open. private -- implementation removed end AWS.Server.Push; AWS.Server.Status ================= ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2003 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: aws-server-status.ads,v 1.4 2003/09/06 16:36:59 obry Exp $ -- This package provides routine to retrieve server's internal status with Ada.Calendar; with AWS.Templates; package AWS.Server.Status is function Translations (Server : in HTTP) return Templates.Translate_Table; -- Returns a translate table to be used with a template file. This table -- contains all internal server's data. This table is used by the server -- internal status page for example. function Start_Time (Server : in HTTP) return Ada.Calendar.Time; -- Returns the server's start time function Resources_Served (Server : in HTTP) return Natural; -- Returns the total number of resources (static file, templates, -- in-memory string) served by the server. function Socket (Server : in HTTP) return Net.Std.Socket_Type; -- Returns the server's socket function Current_Connections (Server : in HTTP) return Natural; -- Returns the current number of connections function Is_Session_Activated (Server : in HTTP) return Boolean; -- Returns True if the session feature has been activated function Is_Security_Activated (Server : in HTTP) return Boolean; -- Returns True if the HTTPS protocol is used function Is_Shutdown (Server : in HTTP) return Boolean; -- Returns True if server has been stopped (the server could still be in -- the shutdown phase). end AWS.Server.Status; AWS.Services.Directory ====================== ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2000-2003 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: aws-services-directory.ads,v 1.7 2003/09/06 17:44:33 obry Exp $ with AWS.Status; with Templates_Parser; -- This service can be used to browse a file system. The browsing mechanism -- will gather information (filename, size, directory...) from a specified -- directory name and will fill a translation table. This table will be used -- with a template file to render the HTML document. You can design your own -- browsing template file, here is a description of all tag variables defined -- in the translation table: -- -- URI (discrete) -- The URI pointing to the directory parsed. -- -- VERSION (discrete) -- AWS version string. -- -- IS_DIR_V (vector) -- A list of booleans, indicate if Nth entry is a directory or not. -- -- NAME_V (vector) -- A list of filenames. Nth name is a directory if Nth entry in IS_DIR -- is set to true. -- -- SIZE_V (vector) -- A list of sizes. Nth entry is the file size of the Nth entry in -- NAMES. -- -- TIME_V (vector) -- A list of last modification times. Nth entry is is the last -- modification time of the Nth entry in NAMES. -- -- NAME_ORDR -- Rule to either set ordering on name or to revert current name -- ordering. -- -- SNME_ORDR -- Rule to either set ordering on name (case sensitive) or to revert -- current name (case sensitive) ordering. -- -- EXT_ORDR -- Rule to either set ordering on extension or to revert current -- extension ordering. -- -- SEXT_ORDR -- Rule to either set ordering on extension (case sensitive) or to -- revert current extension (case sensitive) ordering. -- -- MIME_ORDR -- Rule to either set ordering on MIME type or to revert current MIME -- type ordering. -- -- DIR_ORDR -- Rule to either set ordering on directory or to revert current -- directory ordering. -- -- SIZE_ORDR -- Rule to either set ordering on size or to revert current size -- ordering. -- -- TIME_ORDR -- Rule to either set ordering on time or to revert current time -- ordering. -- -- ORIG_ORDR -- Rule to either set original ordering (file order as read on the file -- system) or to revert current original ordering. -- -- DIR_NAME_ORDR -- Rule to either set ordering on directory/name or to revert current -- directory/name ordering. -- -- DIR_SNME_ORDR -- Rule to either set ordering on directory/name (case sensitive) or to -- revert current directory/name (case sensitive) ordering. -- -- DIR_TIME_ORDR -- Rule to either set ordering on directory/time or to revert current -- directory/time ordering. -- package AWS.Services.Directory is use Templates_Parser; function Browse (Directory_Name : in String; Request : in AWS.Status.Data) return Translate_Table; -- Returns a translation table containing information parsed from -- Directory_Name. This is supposed to be used with a directory template. function Browse (Directory_Name : in String; Template_Filename : in String; Request : in AWS.Status.Data; Translations : in Translate_Table := No_Translation) return String; -- Parses directory Directory_Name and use Templates_Parser to fill in the -- template Template_Filename. It is possible to specified some specifics -- tags in Translations. end AWS.Services.Directory; AWS.Services.Dispatchers ======================== ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2000-2001 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: aws-services-dispatchers.ads,v 1.5 2003/12/10 22:05:22 obry Exp $ package AWS.Services.Dispatchers is pragma Pure; -- Services on the Dispatcher tree are to help building big servers. -- Experiences shows that a lot of user's code is to check the value of a -- specific URI or request method to call the right callback that will -- handle the request. This code is a big "if/elsif/end if" that just hide -- the real job. A dispatcher is to replace this code. Currently there is -- three of them: -- -- URI (AWS.Services.Dispatchers.URI) -- to dispatch to a callback depending of the ressource name. -- -- Method (AWS.Services.Dispatchers.Method) -- to dispatch to a callback depending of the request method. -- -- Virtual_Host (AWS.Services.Dispatchers.Virtual_Host) -- to dispatch to a callback depending on the host name. This is known -- as virtual hosting and permit to have multiple servers on the same -- machine using the same port. -- -- Transient_Pages (AWS.Services.Dispatchers.Transient_Pages) -- to handle transient pages, if the default user's callback returns -- 404 this dispatcher checks if the requested resource is a transient -- page. -- -- Timer (AWS.Services.Dispatchers.Timer) -- to dispatch to a specific callback depending on the current time. end AWS.Services.Dispatchers; AWS.Services.Dispatchers.Method =============================== ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2000-2003 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $RCSfile: aws-services-dispatchers-method.ads,v $ -- $Revision: 1.5 $ $Date: 2003/12/09 14:00:02 $ $Author: obry $ -- Dispatch a specific request to a callback depending on the request method. with AWS.Dispatchers; with AWS.Response; with AWS.Status; package AWS.Services.Dispatchers.Method is type Handler is new AWS.Dispatchers.Handler with private; function Dispatch (Dispatcher : in Handler; Request : in Status.Data) return Response.Data; procedure Register (Dispatcher : in out Handler; Method : in Status.Request_Method; Action : in AWS.Dispatchers.Handler'Class); -- Register callback to use for a specific request method. procedure Register (Dispatcher : in out Handler; Method : in Status.Request_Method; Action : in Response.Callback); -- Idem as above but take a callback procedure as parameter. procedure Unregister (Dispatcher : in out Handler; Method : in Status.Request_Method); -- Removes Method from the list of request method to handle. procedure Register_Default_Callback (Dispatcher : in out Handler; Action : in AWS.Dispatchers.Handler'Class); -- Register the default callback. This will be used if no request method -- have been activated. private -- implementation removed end AWS.Services.Dispatchers.Method; AWS.Services.Dispatchers.URI ============================ ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2000-2003 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $RCSfile: aws-services-dispatchers-uri.ads,v $ -- $Revision: 1.10 $ $Date: 2003/12/08 14:28:07 $ $Author: obry $ -- Dispatch a specific request to a callback depending on the URI. with Ada.Strings.Unbounded; with GNAT.Dynamic_Tables; with AWS.Dispatchers; with AWS.Response; with AWS.Status; package AWS.Services.Dispatchers.URI is type Handler is new AWS.Dispatchers.Handler with private; function Dispatch (Dispatcher : in Handler; Request : in Status.Data) return Response.Data; -- Dispatch will return the value returned by the first callback matching -- the request. Note that if a callback returns the Response.Empty -- message, Dispatch will just continue to the next matching callback. In -- any cases, if no handler matches it will call the default callback. If -- no default callback is registered an error HTML message will be -- returned. procedure Register (Dispatcher : in out Handler; URI : in String; Action : in AWS.Dispatchers.Handler'Class); -- Register URI to use the specified dispatcher. URI is the full string -- that must match the ressource requested (with the leading /). procedure Register (Dispatcher : in out Handler; URI : in String; Action : in Response.Callback); -- Idem as above but take a callback procedure as parameter. procedure Register_Regexp (Dispatcher : in out Handler; URI : in String; Action : in AWS.Dispatchers.Handler'Class); -- Register URI to use the specified dispatcher. URI is a regular -- expression that must math the ressource requested (with the leading /). procedure Register_Regexp (Dispatcher : in out Handler; URI : in String; Action : in Response.Callback); -- Idem as above but take a callback procedure as parameter. procedure Unregister (Dispatcher : in out Handler; URI : in String); -- Removes URI from the list. URI is either a name or a regexp and must -- have exactaly the value used with Register. procedure Register_Default_Callback (Dispatcher : in out Handler; Action : in AWS.Dispatchers.Handler'Class); -- Register the default callback. This will be used if no URI match -- the request. private -- implementation removed end AWS.Services.Dispatchers.URI; AWS.Services.Dispatchers.Virtual_Host ===================================== ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2000-2001 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $RCSfile: aws-services-dispatchers-virtual_host.ads,v $ -- $Revision: 1.4 $ $Date: 2003/12/08 14:28:04 $ $Author: obry $ with Ada.Strings.Unbounded; with Table_Of_Strings_And_Static_Values_G; with AWS.Dispatchers; with AWS.Response; with AWS.Status; package AWS.Services.Dispatchers.Virtual_Host is type Handler is new AWS.Dispatchers.Handler with private; function Dispatch (Dispatcher : in Handler; Request : in Status.Data) return Response.Data; procedure Register (Dispatcher : in out Handler; Virtual_Hostname : in String; Hostname : in String); -- Register Virtual_Hostname to be a redirection to the specified -- hostname. procedure Register (Dispatcher : in out Handler; Virtual_Hostname : in String; Action : in AWS.Dispatchers.Handler'Class); -- Register Virtual_Hostname to use the specified callback. procedure Register (Dispatcher : in out Handler; Virtual_Hostname : in String; Action : in Response.Callback); -- Idem as above but take a callback procedure as parameter. procedure Unregister (Dispatcher : in out Handler; Virtual_Hostname : in String); -- Removes Virtual_Hostname from the list of virtual hostnames to handle. procedure Register_Default_Callback (Dispatcher : in out Handler; Action : in AWS.Dispatchers.Handler'Class); -- Register the default callback. This will be used if no Virtual_Hostname -- match the request. private -- implementation removed end AWS.Services.Dispatchers.Virtual_Host; AWS.Services.Page_Server ======================== ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2000-2001 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: aws-services-page_server.ads,v 1.4 2002/10/06 16:20:20 obry Exp $ -- The Callback is an implementation of a simple static Web page server. It -- will return the Web pages found in the Web server directory. If directory -- browsing is activated, it will be possible to browse directory content if -- the requested ressource is a directory. There is two specials files that -- are recognized: -- -- 404.thtml The Web page returned if the requested page is -- not found. This is a template with a single tag -- variable named PAGE. It will be replaced by the -- ressource which was not found. -- -- Note that on Microsoft IE this page will be -- displayed only if the total page size is bigger -- than 512 bytes or it includes at least one -- image. -- -- aws_directory.thtml The template page used for directory browsing. -- See AWS.Services.Directory for a full description -- of this template usage. with AWS.Status; with AWS.Response; package AWS.Services.Page_Server is procedure Directory_Browsing (Activated : in Boolean); -- If Activated is set to True the directory browsing faciity will be -- activated. By default this feature is not activated. function Callback (Request : in AWS.Status.Data) return AWS.Response.Data; -- This is the AWS callback for the simple static Web pages server. end AWS.Services.Page_Server; AWS.Services.Split_Pages ======================== ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2003 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: aws-services-split_pages.ads,v 1.2 2003/12/08 14:27:54 obry Exp $ with AWS.Response; with AWS.Templates; package AWS.Services.Split_Pages is -- This package provides an API to split a big table in multiple pages -- using the transient Web Pages support. In the template file a set of -- specific tags are recongnized: -- -- NEXT The href to the next page. -- PREVIOUS The href to the previous page. -- PAGE_INDEX Current page number. -- NUMBER_PAGES Number of pages generated. -- OFFSET Current table line offset real table line can be computed -- using: @_"+"(OFFSET):TABLE_LINE_@ -- HREFS_V A vector tag containing a set of href to pages. -- INDEXES_V A vector tag (synchronized with HREFS_V) containing the -- page numnbers for the hrefs. -- -- HREFS_V and INDEXES_V can be used to create an index to the generated -- pages. Note that if there is more pages than Max_In_Index a -- continuation (the 3 characters "...") will be added. function Parse (Template : in String; Translations : in Templates.Translate_Table; Table : in Templates.Translate_Table; Max_Per_Page : in Positive := 25; Max_In_Index : in Positive := 20; Cached : in Boolean := True) return Response.Data; -- Parse the Template file and split the result in multiple pages. -- Translations is a standard Translate_Table used for all pages. Table -- is the Translate_Table containing data for the table to split in -- multiple pages. This table will be analysed and according to the -- Max_Per_Page value a set of transient pages will be created. -- Max_In_Index is the maximum number of items in the page index. If -- Cached is True the template will be cached (see Templates_Parser -- documentation). end AWS.Services.Split_Pages; AWS.Services.Transient_Pages ============================ ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2003 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: aws-services-transient_pages.ads,v 1.4 2003/11/12 22:53:07 obry Exp $ with AWS.Default; with AWS.Resources.Streams; package AWS.Services.Transient_Pages is function Get_URI return String; -- Create a unique URI, must be used to register a transient web page procedure Register (URI : in String; Resource : in AWS.Resources.Streams.Stream_Access; Lifetime : in Duration := Default.Transient_Lifetime); -- Register a new transient page, this page will be deleted after Lifetime -- seconds. function Get (URI : in String) return AWS.Resources.Streams.Stream_Access; -- Returns the stream access for the URI or null if this URI has not been -- registered. private -- implementation removed end AWS.Services.Transient_Pages; AWS.Session =========== ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2000-2004 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: aws-session.ads,v 1.26 2004/01/31 19:21:30 obry Exp $ -- This is the API to handle session data for each client connected. with Ada.Calendar; package AWS.Session is type ID is private; No_Session : constant ID; function Create return ID; -- Create a new uniq Session ID. procedure Delete (SID : in ID); -- Delete session, does nothing if SID does not exists. function Image (SID : in ID) return String; pragma Inline (Image); -- Return ID image function Value (SID : in String) return ID; pragma Inline (Value); -- Build an ID from a String, returns No_Session if SID is not recongnized -- as an AWS session ID. function Exist (SID : in ID) return Boolean; -- Returns True if SID exist procedure Touch (SID : in ID); -- Update to current time the timestamp associated with SID. Does nothing -- if SID does not exists. procedure Set (SID : in ID; Key : in String; Value : in String); -- Set key/pair value for the SID procedure Set (SID : in ID; Key : in String; Value : in Integer); -- Set key/pair value for the SID procedure Set (SID : in ID; Key : in String; Value : in Float); -- Set key/pair value for the SID procedure Set (SID : in ID; Key : in String; Value : in Boolean); -- Set key/pair value for the SID function Get (SID : in ID; Key : in String) return String; pragma Inline (Get); -- Returns the Value for Key in the session SID or the emptry string if -- key does not exist. function Get (SID : in ID; Key : in String) return Integer; pragma Inline (Get); -- Returns the Value for Key in the session SID or the integer value 0 if -- key does not exist or is not an integer. function Get (SID : in ID; Key : in String) return Float; pragma Inline (Get); -- Returns the Value for Key in the session SID or the float value 0.0 if -- key does not exist or is not a float. function Get (SID : in ID; Key : in String) return Boolean; pragma Inline (Get); -- Returns the Value for Key in the session SID or the boolean False if -- key does not exist or is not a boolean. generic type Data is private; Null_Data : Data; package Generic_Data is procedure Set (SID : in ID; Key : in String; Value : in Data); -- Set key/pair value for the SID function Get (SID : in ID; Key : in String) return Data; pragma Inline (Get); -- Returns the Value for Key in the session SID or Null_Data if -- key does not exist. end Generic_Data; procedure Remove (SID : in ID; Key : in String); -- Removes Key from the specified session. function Exist (SID : in ID; Key : in String) return Boolean; -- Returns True if Key exist in session SID. --------------- -- Iterators - --------------- generic with procedure Action (N : in Positive; SID : in ID; Time_Stamp : in Ada.Calendar.Time; Quit : in out Boolean); procedure For_Every_Session; -- Iterator which call Action for every active session. N is the SID -- order. Time_Stamp is the time when SID was updated for the last -- time. Quit is set to False by default, it is possible to control the -- iterator termination by setting its value to True. Note that in the -- Action procedure it is possible to use routines that read session's -- data (Get, Exist) but any routines which modify the data will block -- (i.e. Touch, Set, Remove, Delete will dead lock). generic with procedure Action (N : in Positive; Key, Value : in String; Quit : in out Boolean); procedure For_Every_Session_Data (SID : in ID); -- Iterator which returns all the key/value pair defined for session SID. -- Quit is set to False by default, it is possible to control the iterator -- termination by setting its value to True. Note that in the Action -- procedure it is possible to use routines that read session's data (Get, -- Exist) but any routines which modify the data will block (i.e. Touch, -- Set, Remove, Delete will dead lock). -------------- -- Lifetime - -------------- procedure Set_Lifetime (Seconds : in Duration); -- Set the lifetime for session data. function Get_Lifetime return Duration; -- Get current session lifetime for session data. ---------------------- -- Session Callback - ---------------------- type Callback is access procedure (SID : in ID); -- Callback procedure called when a sesssion is deleted from the server. procedure Set_Callback (Callback : in Session.Callback); -- Set the callback procedure to call when a session is deleted from the -- server. If Callback is Null the session's callback will be removed. ---------------- -- Session IO - ---------------- procedure Save (File_Name : in String); -- Save all sessions data into File_Name. procedure Load (File_Name : in String); -- Restore all sessions data from File_Name. private -- implementation removed end AWS.Session; AWS.SMTP ======== ------------------------------------------------------------------------------ -- Ada Web Server - -- S M T P - Simple Mail Transfer Protocol - -- - -- Copyright (C) 2000-2004 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: aws-smtp.ads,v 1.4 2004/04/06 12:18:23 obry Exp $ -- This library implement the Simple Mail Transfer Protocol. Only part of the -- RFC 821 is covered. There is no support to send a message to a console for -- example. with Ada.Strings.Unbounded; with AWS.Net; package AWS.SMTP is Server_Error : exception; -- Raised when an unrecoverable error is found. Reply_Code_Error : exception; -- Raised when a reply code error is not known. Default_SMTP_Port : constant := 25; type Receiver is private; -- The receiver part (i.e. a server) of SMTP messages as defined in -- RFC 821. This is the SMTP server ---------------- -- Reply_Code - ---------------- type Reply_Code is range 200 .. 554; Service_Ready : constant Reply_Code := 220; Service_Closing : constant Reply_Code := 221; Requested_Action_Ok : constant Reply_Code := 250; Start_Mail_Input : constant Reply_Code := 354; Syntax_Error : constant Reply_Code := 500; function Image (R : in Reply_Code) return String; -- Returns the reply code as a string. Raises Reply_Code_Error if R is -- not a valid reply code. function Name (R : in Reply_Code) return String; -- Returns the reply code reason string. Raises Reply_Code_Error if R is -- not a valid reply code. function Message (R : in Reply_Code) return String; -- This returns the value: Image (R) & ' ' & Name (R) ------------ -- Status - ------------ type Status is private; function Is_Ok (Status : in SMTP.Status) return Boolean; pragma Inline (Is_Ok); -- Return True is status if Ok (no problem) or false if a problem has been -- detected. This is not an error (in that case Error is raised) but a -- warning because something wrong (but not unrecoverable) has happen. function Status_Message (Status : in SMTP.Status) return String; -- If Is_Ok is False, this function return the reason of the problem. The -- return message is the error message as reported by the server. function Status_Code (Status : in SMTP.Status) return Reply_Code; pragma Inline (Status_Code); -- Returns the code replied by the server. procedure Clear (Status : in out SMTP.Status); pragma Inline (Clear); -- Clear Status value. Code is set to Requested_Action_Ok and message -- string to null. ----------------- -- E_Mail_Data - ----------------- type E_Mail_Data is private; type Address_Mode is (Full, Name, Address); function Image (E_Mail : in E_Mail_Data; Mode : in Address_Mode := Full) return String; -- Returns E_Mail only (Mode = Address), recipient name only (Mode = Name) -- or Name and e-mail (Mode = Full). function E_Mail (Name : in String; Address : in String) return E_Mail_Data; -- Returns an e-mail address function Parse (E_Mail : in String) return E_Mail_Data; -- Parse an e-mail with format "Name
" or "address (Name)" -- and Returns the corresponding E_Mail_Data. Raises Contraint_Error -- if E_Mail can't be parsed. type Recipients is array (Positive range <>) of E_Mail_Data; private -- implementation removed end AWS.SMTP; AWS.SMTP.Client =============== ------------------------------------------------------------------------------ -- Ada Web Server - -- S M T P - Simple Mail Transfer Protocol - -- - -- Copyright (C) 2000-2002 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: aws-smtp-client.ads,v 1.2 2003/11/03 22:19:14 obry Exp $ -- -- This unit implement API to send mail message. It is possible to send -- simple mail [RFC 821] and mail with MIME attachments [RFC 2045 & 2049]. -- -- How to send a mail: -- -- 1) Initialize a Server to send the messages. -- -- Wanadoo : SMTP.Server := SMTP.Client.Initialize ("smtp.wanadoo.fr"); -- -- 2) Send a message via this server. -- -- Result : SMTP.Status; -- -- SMTP.Client.Send -- (Server => Wanadoo, -- From => SMTP.E_Mail ("Pascal Obry", "p.obry@wanadoo.fr"), -- To => SMTP.E_Mail -- ("Dmitriy Anisimkov", "anisimkov@omsknet.ru"), -- Subject => "Latest Ada news", -- Message => "now Ada can send SMTP mail!", -- Status => Result); with Ada.Strings.Unbounded; package AWS.SMTP.Client is use Ada.Strings.Unbounded; function Initialize (Server_Name : in String; Port : in Positive := Default_SMTP_Port) return Receiver; -- Create a Server composed of the Name and the Port (default SMTP port -- is 25), this server will be used to send SMTP message. procedure Send (Server : in Receiver; From : in E_Mail_Data; To : in E_Mail_Data; Subject : in String; Message : in String; Status : out SMTP.Status); -- Send a message via Server. The mail is a simple message composed of a -- subject and a text message body. Raise Server_Error in case of an -- unrecoverable error (e.g. can't contact the server). type Attachment is private; -- This is an attachment object, either a File or a Base64 content. function File (Filename : in String) return Attachment; -- Returns a file attachment. Filename point to a file on the file system. function Base64_Data (Name, Content : in String) return Attachment; -- Returns a base64 attachment. Content is the Base64 encoded -- data. Attachment is named Name. This is a way to send a file attachment -- from in-memory data. type Attachment_Set is array (Positive range <>) of Attachment; -- A set of file attachments. procedure Send (Server : in Receiver; From : in E_Mail_Data; To : in E_Mail_Data; Subject : in String; Message : in String; Attachments : in Attachment_Set; Status : out SMTP.Status); -- Send a message via Server. The mail is a MIME message composed of a -- subject, a message and a set of files MIME encoded. Raise Server_Error -- in case of an unrecoverable error (e.g. can't contact the server). -- Raises Constraint_Error is a file attachment cannot be opened. type Message_File is new String; procedure Send (Server : in Receiver; From : in E_Mail_Data; To : in E_Mail_Data; Subject : in String; Filename : in Message_File; Status : out SMTP.Status); -- Send filename content via Server. The mail is a message composed of a -- subject and a message body coming from a file. Raises Server_Error in -- case of an unrecoverable error (e.g. can't contact the server). Raises -- Constraint_Error if Filename cannot be opened. -- -- Extentded interfaces to send a message to many recipients. -- procedure Send (Server : in Receiver; From : in E_Mail_Data; To : in Recipients; Subject : in String; Message : in String; Status : out SMTP.Status); -- Send a message via Server. The mail is a simple message composed of a -- subject and a text message body. Raise Server_Error in case of an -- unrecoverable error (e.g. can't contact the server). procedure Send (Server : in Receiver; From : in E_Mail_Data; To : in Recipients; Subject : in String; Message : in String; Attachments : in Attachment_Set; Status : out SMTP.Status); -- Send a message via Server. The mail is a MIME message composed of a -- subject, a message and a set of files MIME encoded. Raise Server_Error -- in case of an unrecoverable error (e.g. can't contact the server). -- Raises Constraint_Error is a file attachment cannot be opened. private -- implementation removed end AWS.SMTP.Client; AWS.Status ========== ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2000-2003 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: aws-status.ads,v 1.50 2003/10/09 09:29:01 anisimko Exp $ -- This package is used to keep the HTTP protocol status. Client can then -- request the status for various values like the requested URI, the -- Content_Length and the Session ID for example. with Ada.Streams; with Ada.Strings.Unbounded; with AWS.Headers; with AWS.Messages; with AWS.Net; with AWS.Parameters; with AWS.Session; with AWS.URL; with AWS.Utils; package AWS.Status is type Data is private; type Request_Method is (GET, HEAD, POST, PUT); type Authorization_Type is (None, Basic, Digest); ------------------ -- Request-Line - ------------------ function Method (D : in Data) return Request_Method; pragma Inline (Method); -- Returns the request method. function URI (D : in Data) return String; pragma Inline (URI); -- Returns the requested resource. function URI (D : in Data) return URL.Object; pragma Inline (URI); -- As above but return an URL object. function HTTP_Version (D : in Data) return String; pragma Inline (HTTP_Version); -- Returns the HTTP version used by the client. ------------ -- Header - ------------ function Header (D : in Data) return Headers.List; pragma Inline (Header); -- Returns the list of header lines for the request. function Accept_Encoding (D : in Data) return String; pragma Inline (Accept_Encoding); -- Get the value for "Accept-Encoding:" header function Connection (D : in Data) return String; pragma Inline (Connection); -- Get the value for "Connection:" parameter function Content_Length (D : in Data) return Natural; pragma Inline (Content_Length); -- Get the value for "Content-Length:" header, this is the number of -- bytes in the message body. function Content_Type (D : in Data) return String; pragma Inline (Content_Type); -- Get value for "Content-Type:" header function Host (D : in Data) return String; pragma Inline (Host); -- Get value for "Host:" header function If_Modified_Since (D : in Data) return String; pragma Inline (If_Modified_Since); -- Get value for "If-Modified-Since:" header function Keep_Alive (D : in Data) return Boolean; pragma Inline (Keep_Alive); -- Returns the flag if the current HTTP connection is keep-alive. function User_Agent (D : in Data) return String; pragma Inline (User_Agent); -- Get value for "User-Agent:" header function Referer (D : in Data) return String; pragma Inline (Referer); -- Get value for "Referer:" header function Is_Supported (D : in Data; Encoding : in Messages.Content_Encoding) return Boolean; -- Returns True if the content encoding scheme is sported by the client function Preferred_Coding (D : in Data) return Messages.Content_Encoding; -- Returns supported by AWS coding preferred by client from the -- Accept-Coding header. ---------------- -- Connection - ---------------- function Peername (D : in Data) return String; pragma Inline (Peername); -- Returns the name of the peer (the name of the client computer) function Socket (D : in Data) return Net.Socket_Type'Class; pragma Inline (Socket); -- Returns the socket used to transfert data between the client and -- server. ---------- -- Data - ---------- function Multipart_Boundary (D : in Data) return String; pragma Inline (Multipart_Boundary); -- Get value for the boundary part in "Content-Type: ...; boundary=..." -- parameter. This is a string that will be used to separate each chunk of -- data in a multipart message. subtype Stream_Element_Array is Ada.Streams.Stream_Element_Array; function Binary_Data (D : in Data) return Stream_Element_Array; pragma Inline (Binary_Data); -- Returns the binary data message content. function Parameters (D : in Data) return Parameters.List; pragma Inline (Parameters); -- Returns the list of parameters for the request. This list can be empty -- if there was no form or URL parameters. ------------- -- Session - ------------- function Has_Session (D : in Data) return Boolean; pragma Inline (Has_Session); -- Returns true if a session ID has been received. function Session (D : in Data) return Session.ID; pragma Inline (Session); -- Returns the Session ID for the request. Raises Constraint_Error if -- server's session support not activated. function Session_Created (D : in Data) return Boolean; -- Returns True if session was just created and is going to be sent to -- client. ---------- -- SOAP - ---------- function Is_SOAP (D : in Data) return Boolean; pragma Inline (Is_SOAP); -- Returns True if it is a SOAP request. In this case SOAPAction return -- the SOAPAction header and Payload returns the XML SOAP Payload message. function SOAPAction (D : in Data) return String; pragma Inline (SOAPAction); -- Get value for "SOAPAction:" parameter. This is a standard header to -- support SOAP over HTTP protocol. function Payload (D : in Data) return String; pragma Inline (Payload); -- Returns the XML Payload message. XML payload is the actual SOAP -- request. ----------- -- HTTPS - ----------- function Check_Digest (D : in Data; Password : in String) return Messages.Status_Code; -- This function is used by the digest authentication to check if the -- client password and authentication parameters are correct. -- The password is not transferred between the client and the server, -- the server check that the client knows the right password using the -- MD5 checksum. -- Returns Messages.S200 in case of successful authentication, -- Messages.S400 in case of wrong authentication request -- (RFC 2617 3.2.2, 3.2.2.5), -- and Messages.S401 in case of authentication error. function Check_Digest (D : in Data; Password : in String) return Boolean; -- The same as above, but do not distinguish wrong requests and -- authentication errors. function Authorization_Mode (D : in Data) return Authorization_Type; pragma Inline (Authorization_Mode); -- Get the type of the "Authorization:" parameter function Authorization_Name (D : in Data) return String; pragma Inline (Authorization_Name); -- Get the value for the name in the "Authorization:" parameter function Authorization_Password (D : in Data) return String; pragma Inline (Authorization_Password); -- Get the value for the password in the "Authorization:" parameter function Authorization_Realm (D : in Data) return String; pragma Inline (Authorization_Realm); -- Get the value for the "realm" in the "Authorization:" parameter function Authorization_Nonce (D : in Data) return String; pragma Inline (Authorization_Nonce); -- Get the value for the "nonce" in the "Authorization:" parameter function Authorization_NC (D : in Data) return String; pragma Inline (Authorization_NC); -- Get the value for the "nc" in the "Authorization:" parameter function Authorization_CNonce (D : in Data) return String; pragma Inline (Authorization_CNonce); -- Get the value for the "cnonce" in the "Authorization:" parameter function Authorization_QOP (D : in Data) return String; pragma Inline (Authorization_QOP); -- Get the value for the "qop" in the "Authorization:" parameter function Authorization_Response (D : in Data) return String; pragma Inline (Authorization_Response); -- Get the value for the "response" in the "Authorization:" parameter private -- implementation removed end AWS.Status; AWS.Templates ============= ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2000-2001 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: aws-templates.ads,v 1.1 2002/01/26 15:54:24 obry Exp $ with Templates_Parser; package AWS.Templates renames Templates_Parser; AWS.Translator ============== ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2000-2003 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: aws-translator.ads,v 1.18 2003/12/18 18:28:34 obry Exp $ with Ada.Streams; with Ada.Strings.Unbounded; with AWS.Resources.Streams.Memory.ZLib; with AWS.Utils; package AWS.Translator is package ZL renames AWS.Resources.Streams.Memory.ZLib; ------------ -- Base64 - ------------ function Base64_Encode (Data : in Ada.Streams.Stream_Element_Array) return String; -- Encode Data using the base64 algorithm function Base64_Encode (Data : in String) return String; -- Same as above but takes a string as input function Base64_Decode (B64_Data : in String) return Ada.Streams.Stream_Element_Array; -- Decode B64_Data using the base64 algorithm -------- -- QP - -------- function QP_Decode (QP_Data : in String) return String; -- Decode QP_Data using the Quoted Printable algorithm ------------------------------------ -- String to Stream_Element_Array - ------------------------------------ function To_String (Data : in Ada.Streams.Stream_Element_Array) return String; pragma Inline (To_String); -- Convert a Stream_Element_Array to a string. Note that as this routine -- returns a String it should not be used with large array as this could -- break the stack size limit. Use the routine below for large array. function To_Stream_Element_Array (Data : in String) return Ada.Streams.Stream_Element_Array; pragma Inline (To_Stream_Element_Array); -- Convert a String to a Stream_Element_Array. function To_Unbounded_String (Data : in Ada.Streams.Stream_Element_Array) return Ada.Strings.Unbounded.Unbounded_String; -- Convert a Stream_Element_Array to an Unbounded_String. -------------------------- -- Compress/Decompress - -------------------------- subtype Compression_Level is ZL.Compression_Level; Default_Compression : constant Compression_Level := ZL.Default_Compression; function Compress (Data : in Ada.Streams.Stream_Element_Array; Level : in Compression_Level := Default_Compression; Header : in ZL.Header_Type := ZL.Default_Header) return Utils.Stream_Element_Array_Access; -- Returns Data compressed with a standard deflate algorithm based on the -- zlib library. The result is dynamically allocated and must be -- explicitly freed. function Decompress (Data : in Ada.Streams.Stream_Element_Array; Header : in ZL.Header_Type := ZL.Default_Header) return Utils.Stream_Element_Array_Access; -- Returns Data decompressed based on the zlib library. The results is -- dynamically allocated and must be explicitly freed. end AWS.Translator; AWS.URL ======= ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2000-2004 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: aws-url.ads,v 1.16 2004/03/17 20:06:07 obry Exp $ with Ada.Strings.Maps; with Ada.Strings.Unbounded; package AWS.URL is use Ada; -- The general URL form as described in RFC2616 is: -- -- http_URL = "http:" "//" host [ ":" port ] [ abs_path [ "?" query ]] -- -- Note also that there are different RFC describing URL like the 2616 and -- 1738 but they use different terminologies. Here we try to follow the -- names used in RFC2616 but we have implemented some extensions at the -- end of this package. For example the way Path and File are separated or -- the handling of user/password which is explicitly not allowed in the -- RFC but are used and supported in many browsers. Here are the extended -- URL supported: -- -- http://username:password@www.here.com:80/dir1/dir2/xyz.html?p=8&x=doh -- | | | | | | -- protocol host port path file parameters -- -- <- pathname -> type Object is private; URL_Error : exception; Default_HTTP_Port : constant := 80; Default_HTTPS_Port : constant := 443; function Parse (URL : in String; Check_Validity : in Boolean := True; Normalize : in Boolean := False) return Object; -- Parse an URL and return an Object representing this URL. It is then -- possible to extract each part of the URL with the services bellow. -- Raises URL_Error if Check_Validity is true and the URL reference a -- resource above the web root directory. procedure Normalize (URL : in out Object); -- Removes all occurrences to parent directory ".." and current directory -- ".". Raises URL_Error if the URL reference a resource above the Web -- root directory. function Is_Valid (URL : in Object) return Boolean; -- Returns True if the URL is valid (does not reference directory above -- the Web root). function URL (URL : in Object) return String; -- Returns full URL string, this can be different to the URL passed if it -- has been normalized. function Protocol_Name (URL : in Object) return String; -- Returns "http" or "https" depending on the protocol used by URL. function Host (URL : in Object) return String; -- Returns the hostname. function Port (URL : in Object) return Positive; -- Returns the port as a positive. function Port (URL : in Object) return String; -- Returns the port as a string. function Abs_Path (URL : in Object; Encode : in Boolean := False) return String; -- Returns the absolute path. This is the complete resource reference -- without the query part. function Query (URL : in Object; Encode : in Boolean := False) return String; -- Returns the Query part of the URL or the empty string if none was -- specified. Note that character '?' is not part of the Query and is -- therefore not returned. -- -- Below are extended API not part of the RFC 2616 URL specification. -- function User (URL : in Object) return String; -- Returns user name part of the URL. Returns the empty string if user was -- not specified. function Password (URL : in Object) return String; -- Returns user's password part of the URL. Returns the empty string if -- password was not specified. function Server_Name (URL : in Object) return String renames Host; function Security (URL : in Object) return Boolean; -- Returns True if it is a Secure HTTP (HTTPS) URL. function Path (URL : in Object; Encode : in Boolean := False) return String; -- Returns the Path (including the leading slash). If Encode is True then -- the URL will be encoded using the Encode routine. function File (URL : in Object; Encode : in Boolean := False) return String; -- Returns the File. If Encode is True then the URL will be encoded using -- the Encode routine. Not that by File here we mean the latest part of -- the URL, it could be a real file or a diretory into the filesystem. -- Parent and current directories are part of the path. function Parameters (URL : in Object; Encode : in Boolean := False) return String; -- Returns the Parameters (including the starting ? character). If Encode -- is True then the URL will be encoded using the Encode routine. function Pathname (URL : in Object; Encode : in Boolean := False) return String renames Abs_Path; function Pathname_And_Parameters (URL : in Object; Encode : in Boolean := False) return String; -- Returns the pathname and the parameters. This is equivalent to: -- Pathname & Parameters. -- -- URL Encoding and Decoding -- Default_Encoding_Set : constant Strings.Maps.Character_Set; function Encode (Str : in String; Encoding_Set : in Strings.Maps.Character_Set := Default_Encoding_Set) return String; -- Encode Str into a URL-safe form. Many characters are forbiden into an -- URL and needs to be encoded. A character is encoded by %XY where XY is -- the character's ASCII hexadecimal code. For example a space is encoded -- as %20. function Decode (Str : in String) return String; -- This is the oposite of Encode above. private -- implementation removed end AWS.URL; SOAP ==== ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2000-2003 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: soap.ads,v 1.8 2003/05/21 19:12:27 obry Exp $ package SOAP is -- This is the root package for the SOAP implementation. It supports -- SOAP 1.1 specifications. SOAP_Error : exception; -- Will be raised when an error occurs in the SOAP implementation. The -- exception message will described the problem. Version : constant String := "1.2"; -- Version number for this implementation. end SOAP; SOAP.Client =========== ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2000-2003 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: soap-client.ads,v 1.11 2003/10/09 15:15:40 obry Exp $ with AWS.Client; with SOAP.Message.Payload; with SOAP.Message.Response; package SOAP.Client is Not_Specified : String renames AWS.Client.No_Data; function Call (URL : in String; P : in Message.Payload.Object; SOAPAction : in String := Not_Specified; User : in String := Not_Specified; Pwd : in String := Not_Specified; Proxy : in String := Not_Specified; Proxy_User : in String := Not_Specified; Proxy_Pwd : in String := Not_Specified; Timeouts : in AWS.Client.Timeouts_Values := AWS.Client.No_Timeout) return Message.Response.Object'Class; -- Send a SOAP HTTP request to URL address. The P is the Payload and -- SOAPAction is the required HTTP field. If it is not specified then the -- URI (URL resource) will be used for the SOAPAction field. The complete -- format is "URL & '#' & Procedure_Name" (Procedure_Name is retrieved -- from the Payload object. function Call (Connection : in AWS.Client.HTTP_Connection; SOAPAction : in String; P : in Message.Payload.Object) return Message.Response.Object'Class; -- Idem as above, but use an already opened connection end SOAP.Client; SOAP.Dispatchers ================ ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2003 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: soap-dispatchers.ads,v 1.4 2003/06/21 09:45:26 obry Exp $ -- Dispatcher for SOAP requests. with AWS.Dispatchers; with AWS.Response; with AWS.Status; with SOAP.Message.Payload; package SOAP.Dispatchers is type Handler is abstract new AWS.Dispatchers.Handler with private; -- This dispatcher will send SOAP and HTTP requests to different routines type SOAP_Callback is access function (SOAPAction : in String; Payload : in Message.Payload.Object; Request : in AWS.Status.Data) return AWS.Response.Data; -- This is the SOAP Server callback type. SOAPAction is the HTTP header -- SOAPAction value, Payload is the parsed XML payload, request is the -- HTTP request status. function Dispatch_SOAP (Dispatcher : in Handler; SOAPAction : in String; Payload : in Message.Payload.Object; Request : in AWS.Status.Data) return AWS.Response.Data is abstract; -- This dispatch function is called for SOAP requests function Dispatch_HTTP (Dispatcher : in Handler; Request : in AWS.Status.Data) return AWS.Response.Data is abstract; -- This dispatch function is called for standard HTTP requests private -- implementation removed end SOAP.Dispatchers; SOAP.Dispatchers.Callback ========================= ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2003 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: soap-dispatchers-callback.ads,v 1.3 2003/06/21 09:45:36 obry Exp $ -- Dispatch on a Callback procedures. package SOAP.Dispatchers.Callback is type Handler is new Dispatchers.Handler with private; -- This is a simple wrapper around standard callback procedure (access to -- function). It will be used to build dispatchers services and for the -- main server callback. function Create (HTTP_Callback : in AWS.Response.Callback; SOAP_Callback : in Dispatchers.SOAP_Callback) return Handler; -- Build a dispatcher for the specified callback. private -- implementation removed end SOAP.Dispatchers.Callback; SOAP.Message ============ ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2000-2001 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: soap-message.ads,v 1.5 2002/09/18 16:23:47 obry Exp $ with Ada.Strings.Unbounded; with SOAP.Parameters; package SOAP.Message is use Ada.Strings.Unbounded; type Object is tagged private; Default_Name_Space : constant String := "http://mns.org/"; -- Default name space used by AWS if none as been specified. function XML_Image (M : in Object) return Unbounded_String; -- Returns the XML image for the wrapper and parameters. This is designed -- to be used by Payload and Response object. function Name_Space (M : in Object'Class) return String; -- Returns message Namespace. function Wrapper_Name (M : in Object'class) return String; -- Returns wrapper name. function Parameters (M : in Object'class) return SOAP.Parameters.List; -- Returns the parameter. procedure Set_Name_Space (M : in out Object'Class; Name : in String); -- Set message's Namespace. procedure Set_Wrapper_Name (M : in out Object'Class; Name : in String); -- Set message's wrapper name. procedure Set_Parameters (M : in out Object'Class; P_Set : in SOAP.Parameters.List); -- Set message's parameters. private -- implementation removed end SOAP.Message; SOAP.Message.XML ================ ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2000-2001 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: soap-message-xml.ads,v 1.8 2003/12/31 15:55:21 obry Exp $ with Ada.Strings.Unbounded; with SOAP.Message.Payload; with SOAP.Message.Response; package SOAP.Message.XML is use Ada.Strings.Unbounded; function Load_Payload (XML : in String) return Message.Payload.Object; -- Build a Payload object by parsing the XML payload string function Load_Response (XML : in String) return Message.Response.Object'Class; -- Build a Response object (either a standard response or an error -- response) by parsing the XML response string. function Load_Response (XML : in Unbounded_String) return Message.Response.Object'Class; -- As above but using an Unbounded_String function Image (O : in Object'Class) return String; -- Returns XML representation of object O function Image (O : in Object'Class) return Unbounded_String; -- Idem as above but returns an Unbounded_String instead of a String end SOAP.Message.XML; SOAP.Parameters =============== ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2000-2001 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: soap-parameters.ads,v 1.10 2003/12/31 16:04:35 obry Exp $ with Ada.Calendar; with Ada.Strings.Unbounded; with SOAP.Types; package SOAP.Parameters is use Ada.Strings.Unbounded; Max_Parameters : constant := 50; -- This is the maximum number of parameters supported by this -- implementation. type List is private; function Argument_Count (P : in List) return Natural; -- Returns the number of parameters in P function Argument (P : in List; Name : in String) return Types.Object'Class; -- Returns parameters named Name in P. Raises Types.Data_Error if not -- found. function Argument (P : in List; N : in Positive) return Types.Object'Class; -- Returns Nth parameters in P. Raises Types.Data_Error if not found. function Exist (P : in List; Name : in String) return Boolean; -- Returns True if parameter named Name exist in P and False otherwise function Get (P : in List; Name : in String) return Integer; -- Returns parameter named Name in P as an Integer value. Raises -- Types.Data_Error if this parameter does not exist or is not an Integer. function Get (P : in List; Name : in String) return Long_Float; -- Returns parameter named Name in P as a Float value. Raises -- Types.Data_Error if this parameter does not exist or is not a Float. function Get (P : in List; Name : in String) return Long_Long_Float; -- Returns parameter named Name in P as a Float value. Raises -- Types.Data_Error if this parameter does not exist or is not a Double. function Get (P : in List; Name : in String) return String; -- Returns parameter named Name in P as a String value. Raises -- Types.Data_Error if this parameter does not exist or is not a String. function Get (P : in List; Name : in String) return Unbounded_String; -- Idem as above, but return an Unbounded_String function Get (P : in List; Name : in String) return Boolean; -- Returns parameter named Name in P as a Boolean value. Raises -- Types.Data_Error if this parameter does not exist or is not a Boolean. function Get (P : in List; Name : in String) return Ada.Calendar.Time; -- Returns parameter named Name in P as a Time value. Raises -- Types.Data_Error if this parameter does not exist or is not a time. function Get (P : in List; Name : in String) return Types.SOAP_Base64; -- Returns parameter named Name in P as a SOAP Base64 value. Raises -- Types.Data_Error if this parameter does not exist or is not a SOAP -- Base64. function Get (P : in List; Name : in String) return Types.SOAP_Record; -- Returns parameter named Name in P as a SOAP Struct value. Raises -- Types.Data_Error if this parameter does not exist or is not a SOAP -- Struct. function Get (P : in List; Name : in String) return Types.SOAP_Array; -- Returns parameter named Name in P as a SOAP Array value. Raises -- Types.Data_Error if this parameter does not exist or is not a SOAP -- Array. ------------------ -- Constructors - ------------------ function "&" (P : in List; O : in Types.Object'Class) return List; function "+" (O : in Types.Object'Class) return List; ---------------- -- Validation - ---------------- procedure Check (P : in List; N : in Natural); -- Checks that there is exactly N parameters or raise Types.Data_Error. procedure Check_Integer (P : in List; Name : in String); -- Checks that parameter named Name exist and is an Integer value. procedure Check_Float (P : in List; Name : in String); -- Checks that parameter named Name exist and is a Float value. procedure Check_Boolean (P : in List; Name : in String); -- Checks that parameter named Name exist and is a Boolean value. procedure Check_Time_Instant (P : in List; Name : in String); -- Checks that parameter named Name exist and is a Time_Instant value. procedure Check_Base64 (P : in List; Name : in String); -- Checks that parameter named Name exist and is a Base64 value. procedure Check_Null (P : in List; Name : in String); -- Checks that parameter named Name exist and is a Null value. procedure Check_Record (P : in List; Name : in String); -- Checks that parameter named Name exist and is a Record value. procedure Check_Array (P : in List; Name : in String); -- Checks that parameter named Name exist and is an Array value. private -- implementation removed end SOAP.Parameters; SOAP.Types ========== ------------------------------------------------------------------------------ -- Ada Web Server - -- - -- Copyright (C) 2001-2003 - -- ACT-Europe - -- - -- Authors: Dmitriy Anisimkov - Pascal Obry - -- - -- This library is free software; you can redistribute it and/or modify - -- it under the terms of the GNU General Public License as published by - -- the Free Software Foundation; either version 2 of the License, or (at - -- your option) any later version. - -- - -- This library is distributed in the hope that it will be useful, but - -- WITHOUT ANY WARRANTY; without even the implied warranty of - -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - -- General Public License for more details. - -- - -- You should have received a copy of the GNU General Public License - -- along with this library; if not, write to the Free Software Foundation, - -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -- - -- As a special exception, if other files instantiate generics from this - -- unit, or you link this unit with other files to produce an executable, - -- this unit does not by itself cause the resulting executable to be - -- covered by the GNU General Public License. This exception does not - -- however invalidate any other reasons why the executable file might be - -- covered by the GNU Public License. - ------------------------------------------------------------------------------ -- $Id: soap-types.ads,v 1.25 2003/12/31 16:00:16 obry Exp $ -- This package contains all SOAP types supported by this implementation. -- Here are some notes about adding support for a new SOAP type (not a -- container) and the corresponding WSDL support: -- -- 1. Add new type derived from scalar in this package. Implements all -- inherited routines (Image, XML_Image and XML_Type). Implements also -- a constructor for this new type and a routine named V to get the -- value as an Ada type. -- -- 2. In SOAP.WSDL, add the new type name in Parameter_Type. -- -- 3. Add support for this new type in all SOAP.WSDL routines. All routines -- are using a case statement to be sure that it won't compile without -- fixing it first. For obvious reasons, only SOAP.WSDL.To_Type is not -- using a case statement, be sure to do the right change there. with Ada.Calendar; with Ada.Finalization; with Ada.Strings.Unbounded; package SOAP.Types is use Ada.Strings.Unbounded; Data_Error : exception; -- Raised when a variable has not the expected type type Object is abstract tagged private; -- Root type for all SOAP types defined in this package type Object_Access is access all Object'Class; type Object_Safe_Pointer is tagged private; -- A safe pointer to a SOAP object, such objects are controlled so the -- memory is freed automatically. type Object_Set is array (Positive range <>) of Object_Safe_Pointer; -- A set of SOAP types. This is used to build arrays or records. We use -- Positive for the index to have the item index map the SOAP array -- element order. function Image (O : in Object) return String; -- Returns O value image. function XML_Image (O : in Object) return String; -- Returns O value encoded for use by the Payload object or Response -- object. function XML_Type (O : in Object) return String; -- Returns the XML type for the object. function Name (O : in Object'Class) return String; -- Returns name for object O. function "+" (O : in Object'Class) return Object_Safe_Pointer; -- Allocate an object into the heap and return a safe pointer to it. function "-" (O : in Object_Safe_Pointer) return Object'Class; -- Returns the object associated with the safe pointer. type Scalar is abstract new Object with private; -- Scalar types are using a by-copy semantic. type Composite is abstract new Object with private; -- Composite types are using a by-reference semantic for efficiency -- reason. Not that these types are not thread safe. -------------- -- Any Type - -------------- XML_Any_Type : constant String := "xsd:anyType"; -- Not supported by this implementation ----------- -- Array - ----------- XML_Array : constant String := "SOAP-ENC:Array"; XML_Undefined : constant String := "xsd:ur-type"; type SOAP_Array is new Composite with private; function Image (O : in SOAP_Array) return String; function XML_Image (O : in SOAP_Array) return String; function XML_Type (O : in SOAP_Array) return String; function A (V : in Object_Set; Name : in String) return SOAP_Array; function Size (O : in SOAP_Array) return Natural; -- Returns the number of item into the array function V (O : in SOAP_Array; N : in Positive) return Object'Class; -- Returns SOAP_Array item at position N function V (O : in SOAP_Array) return Object_Set; ------------ -- Base64 - ------------ XML_Base64 : constant String := "SOAP-ENC:base64"; XML_Base64_Binary : constant String := "xsd:base64Binary"; type SOAP_Base64 is new Scalar with private; function Image (O : in SOAP_Base64) return String; function XML_Image (O : in SOAP_Base64) return String; function XML_Type (O : in SOAP_Base64) return String; function B64 (V : in String; Name : in String := "item") return SOAP_Base64; function V (O : in SOAP_Base64) return String; ------------- -- Boolean - ------------- XML_Boolean : constant String := "xsd:boolean"; type XSD_Boolean is new Scalar with private; function Image (O : in XSD_Boolean) return String; function XML_Image (O : in XSD_Boolean) return String; function XML_Type (O : in XSD_Boolean) return String; function B (V : in Boolean; Name : in String := "item") return XSD_Boolean; function V (O : in XSD_Boolean) return Boolean; ------------ -- Double - ------------ XML_Double : constant String := "xsd:double"; type XSD_Double is new Scalar with private; function Image (O : in XSD_Double) return String; function XML_Image (O : in XSD_Double) return String; function XML_Type (O : in XSD_Double) return String; function D (V : in Long_Long_Float; Name : in String := "item") return XSD_Double; function V (O : in XSD_Double) return Long_Long_Float; ----------- -- Float - ----------- XML_Float : constant String := "xsd:float"; type XSD_Float is new Scalar with private; function Image (O : in XSD_Float) return String; function XML_Image (O : in XSD_Float) return String; function XML_Type (O : in XSD_Float) return String; function F (V : in Long_Float; Name : in String := "item") return XSD_Float; function V (O : in XSD_Float) return Long_Float; ------------- -- Integer - ------------- XML_Int : constant String := "xsd:int"; type XSD_Integer is new Scalar with private; function Image (O : in XSD_Integer) return String; function XML_Image (O : in XSD_Integer) return String; function XML_Type (O : in XSD_Integer) return String; function I (V : in Integer; Name : in String := "item") return XSD_Integer; function V (O : in XSD_Integer) return Integer; ---------- -- Null - ---------- XML_Null : constant String := "1"; type XSD_Null is new Scalar with private; function XML_Image (O : in XSD_Null) return String; function XML_Type (O : in XSD_Null) return String; function N (Name : in String := "item") return XSD_Null; ------------ -- Record - ------------ type SOAP_Record is new Composite with private; function Image (O : in SOAP_Record) return String; function XML_Image (O : in SOAP_Record) return String; function XML_Type (O : in SOAP_Record) return String; function R (V : in Object_Set; Name : in String; Type_Name : in String := "") return SOAP_Record; -- If Type_Name is omitted then the type name is the name of the record. -- Type_Name must be specified for item into an array for example. function V (O : in SOAP_Record; Name : in String) return Object'Class; -- Returns SOAP_Record field named Name function V (O : in SOAP_Record) return Object_Set; ------------ -- String - ------------ XML_String : constant String := "xsd:string"; type XSD_String is new Scalar with private; function Image (O : in XSD_String) return String; function XML_Image (O : in XSD_String) return String; function XML_Type (O : in XSD_String) return String; function S (V : in String; Name : in String := "item") return XSD_String; function S (V : in Unbounded_String; Name : in String := "item") return XSD_String; function V (O : in XSD_String) return String; function V (O : in XSD_String) return Unbounded_String; ----------------- -- TimeInstant - ----------------- XML_Time_Instant : constant String := "xsd:timeInstant"; XML_Date_Time : constant String := "xsd:dateTime"; type XSD_Time_Instant is new Scalar with private; function Image (O : in XSD_Time_Instant) return String; function XML_Image (O : in XSD_Time_Instant) return String; function XML_Type (O : in XSD_Time_Instant) return String; subtype TZ is Integer range -11 .. +11; GMT : constant TZ := 0; function T (V : in Ada.Calendar.Time; Name : in String := "item"; Timezone : in TZ := GMT) return XSD_Time_Instant; function V (O : in XSD_Time_Instant) return Ada.Calendar.Time; -- Returns a GMT date and time ----------------- -- Enumeration - ----------------- type SOAP_Enumeration is new Scalar with private; function Image (O : in SOAP_Enumeration) return String; function XML_Image (O : in SOAP_Enumeration) return String; function XML_Type (O : in SOAP_Enumeration) return String; function E (V : in String; Type_Name : in String; Name : in String := "item") return SOAP_Enumeration; function V (O : in SOAP_Enumeration) return String; --------- -- Get - --------- function Get (O : in Object'Class) return Integer; -- Returns O value as an Integer. Raises Data_Error if O is not a SOAP -- Integer. function Get (O : in Object'Class) return Long_Float; -- Returns O value as a Long_Float. Raises Data_Error if O is not a SOAP -- Float. function Get (O : in Object'Class) return Long_Long_Float; -- Returns O value as a Long_Long_Float. Raises Data_Error if O is not a -- SOAP Double. function Get (O : in Object'Class) return String; -- Returns O value as a String. Raises Data_Error if O is not a SOAP -- String. function Get (O : in Object'Class) return Unbounded_String; -- As above but returns an Unbounded_String function Get (O : in Object'Class) return Boolean; -- Returns O value as a Boolean. Raises Data_Error if O is not a SOAP -- Boolean. function Get (O : in Object'Class) return Ada.Calendar.Time; -- Returns O value as a Time. Raises Data_Error if O is not a SOAP -- Time. function Get (O : in Object'Class) return SOAP_Base64; -- Returns O value as a SOAP Base64. Raises Data_Error if O is not a SOAP -- Base64 object. function Get (O : in Object'Class) return SOAP_Record; -- Returns O value as a SOAP Struct. Raises Data_Error if O is not a SOAP -- Struct. function Get (O : in Object'Class) return SOAP_Array; -- Returns O value as a SOAP Array. Raises Data_Error if O is not a SOAP -- Array. private -- implementation removed end SOAP.Types; Index ***** ABORTABLE_V: See ``Status page''. ACCEPT_QUEUE_SIZE: See ``Status page''. Accept_Queue_Size: See ``Configuration options''. ACTIVITY_COUNTER_V: See ``Status page''. ACTIVITY_TIME_STAMP_V: See ``Status page''. ada2wsdl <1>: See ``Creating `WSDL' documents''. ada2wsdl: See ``Using `WSDL'''. ada2wsdl limitations: See ```ada2wsdl' limitations''. Admin_URI <1>: See ``Configuration options''. Admin_URI: See ``Building an AWS server''. authentication: See ``Authentication''. AWS: See ``AWS''. AWS.Client: See ``AWS.Client''. AWS.Communication: See ``AWS.Communication''. AWS.Communication.Client: See ``AWS.Communication.Client''. AWS.Communication.Server: See ``AWS.Communication.Server''. AWS.Config: See ``AWS.Config''. AWS.Config.Ini: See ``AWS.Config.Ini''. AWS.Config.Set: See ``AWS.Config.Set''. AWS.Containers.Tables: See ``AWS.Containers.Tables''. AWS.Default: See ``AWS.Default''. AWS.Dispatchers: See ``AWS.Dispatchers''. AWS.Dispatchers.Callback: See ``AWS.Dispatchers.Callback''. AWS.Exceptions: See ``AWS.Exceptions''. AWS.Headers: See ``AWS.Headers''. AWS.Headers.Values: See ``AWS.Headers.Values''. aws.ini: See ``Configuration options''. AWS.Jabber: See ``AWS.Jabber''. AWS.LDAP.Client: See ``AWS.LDAP.Client''. AWS.Log: See ``AWS.Log''. AWS.Messages: See ``AWS.Messages''. AWS.MIME: See ``AWS.MIME''. AWS.Net.SSL: See ``AWS.Net.SSL''. AWS.Net.SSL.Certificate: See ``AWS.Net.SSL.Certificate''. AWS.Net.Std: See ``AWS.Net.Std''. AWS.OS_Lib: See ``AWS.OS_Lib''. AWS.Parameters: See ``AWS.Parameters''. AWS.POP: See ``AWS.POP''. AWS.Resources: See ``AWS.Resources''. AWS.Resources.Embedded: See ``AWS.Resources.Embedded''. AWS.Resources.Files: See ``AWS.Resources.Files''. AWS.Resources.Streams: See ``AWS.Resources.Streams''. AWS.Resources.Streams.Memory: See ``AWS.Resources.Streams.Memory''. AWS.Resources.Streams.Memory.ZLib: See ``AWS.Resources.Streams.Memory.ZLib''. AWS.Response: See ``AWS.Response''. AWS.Server: See ``AWS.Server''. AWS.Server.Hotplug: See ``AWS.Server.Hotplug''. AWS.Server.Log: See ``AWS.Server.Log''. AWS.Server.Push: See ``AWS.Server.Push''. AWS.Server.Status: See ``AWS.Server.Status''. AWS.Services.Directory: See ``AWS.Services.Directory''. AWS.Services.Dispatchers: See ``AWS.Services.Dispatchers''. AWS.Services.Dispatchers.Method: See ``AWS.Services.Dispatchers.Method''. AWS.Services.Dispatchers.URI: See ``AWS.Services.Dispatchers.URI''. AWS.Services.Dispatchers.Virtual_Host: See ``AWS.Services.Dispatchers.Virtual_Host''. AWS.Services.Page_Server: See ``AWS.Services.Page_Server''. AWS.Services.Split_Pages: See ``AWS.Services.Split_Pages''. AWS.Services.Transient_Pages: See ``AWS.Services.Transient_Pages''. AWS.Session: See ``AWS.Session''. AWS.SMTP: See ``AWS.SMTP''. AWS.SMTP.Client: See ``AWS.SMTP.Client''. AWS.Status: See ``AWS.Status''. AWS.Templates: See ``AWS.Templates''. AWS.Translator: See ``AWS.Translator''. AWS.URL: See ``AWS.URL''. awsres: See ``awsres tool''. basic: See ``Authentication''. Building: See ``Building''. Building resources: See ``Building resources''. Callback <1>: See ``Callback procedure''. Callback: See ``Building an AWS server''. Callback procedure: See ``Callback procedure''. Callback, dispatcher: See ``Callback dispatcher''. Callback, dispatcher API: See ``AWS.Dispatchers.Callback''. Case_Sensitive_Parameters <1>: See ``Configuration options''. Case_Sensitive_Parameters: See ``Building an AWS server''. certificate <1>: See ``Creating a test certificate''. certificate: See ``Initialization''. Certificate (string): See ``Configuration options''. Check_URL_Validity: See ``Configuration options''. CLEANER_CLIENT_DATA_TIMEOUT: See ``Status page''. Cleaner_Client_Data_Timeout: See ``Configuration options''. CLEANER_CLIENT_HEADER_TIMEOUT: See ``Status page''. Cleaner_Client_Header_Timeout: See ``Configuration options''. CLEANER_SERVER_RESPONSE_TIMEOUT: See ``Status page''. Cleaner_Server_Response_Timeout: See ``Configuration options''. CLEANER_WAIT_FOR_CLIENT_TIMEOUT: See ``Status page''. Cleaner_Wait_For_Client_Timeout: See ``Configuration options''. client HTTP: See ``Client side''. Client protocol: See ``Client side''. Communication: See ``Communication''. Communication, Client: See ``Communication - client side''. Communication, Server: See ``Communication - server side''. Configuration options: See ``Configuration options''. digest: See ``Authentication''. Directory browser: See ``Directory browser''. Directory_Browser_Page: See ``Configuration options''. Dispatchers: See ``Dispatchers''. Dispatchers callback: See ``Callback dispatcher''. Dispatchers method: See ``Method dispatcher''. Dispatchers SOAP: See ```SOAP' dispatcher''. Dispatchers Timer: See ``Timer dispatcher''. Dispatchers Transient pages: See ``Transient pages dispatcher''. Dispatchers URI: See ``URI dispatcher''. Dispatchers virtual host: See ``Virtual host dispatcher''. Distributing: See ``Distribution of an AWS server''. Down_Image: See ``Configuration options''. draft 302: See ``References''. exception handler: See ``Unexpected exception handler''. Exceptions, Unexpected exceptions, Exceptions handler: See ``AWS.Exceptions''. Exchange_Certificate: See ``Configuration options''. File upload: See ``File upload''. FORCE_CLIENT_DATA_TIMEOUT: See ``Status page''. Force_Client_Data_Timeout: See ``Configuration options''. FORCE_CLIENT_HEADER_TIMEOUT: See ``Status page''. Force_Client_Header_Timeout: See ``Configuration options''. FORCE_SERVER_RESPONSE_TIMEOUT: See ``Status page''. Force_Server_Response_Timeout: See ``Configuration options''. FORCE_WAIT_FOR_CLIENT_TIMEOUT: See ``Status page''. Force_Wait_For_Client_Timeout: See ``Configuration options''. Form parameters: See ``Form parameters''. Free_Slots_Keep_Alive_Limit: See ``Configuration options''. GNAT: See ``Requirements''. GNU/Ada: See ``Requirements''. Hello world: See ``Callback procedure''. hotplug: See ``Hotplug module''. Hotplug_Port: See ``Configuration options''. HTML File Upload: See ``References''. HTTP Authentication: See ``References''. HTTP declaration: See ``Building an AWS server''. HTTP/1.0: See ``References''. HTTP/1.1: See ``References''. HTTPS: See ``Secure server''. IMAP/POP: See ``References''. ini file: See ``Configuration options''. Installing: See ``Installing''. Jabber: See ``Jabber''. Jabber Binding: See ``AWS.Jabber''. Jabber message: See ``Jabber message''. Jabber presence: See ``Jabber presence''. Key: See ``Configuration options''. KEYS_M: See ``Status page''. LDAP: See ``LDAP''. LDAP Binding: See ``AWS.LDAP.Client''. LDAP Directory: See ``LDAP''. libcrypto.a: See ``Building''. libssl.a: See ``Building''. Lightweight Directory Access Protocol: See ``LDAP''. Line_Stack_Size: See ``Configuration options''. LOG: See ``Status page''. Log.Flush: See ``Server Log''. Log.Start: See ``Server Log''. Log.Start_Error: See ``Server Log''. Log.Stop: See ``Server Log''. Log.Stop_Error: See ``Server Log''. LOG_FILE: See ``Status page''. Log_File_Directory: See ``Configuration options''. Log_Filename_Prefix: See ``Configuration options''. LOG_MODE: See ``Status page''. Log_Split_Mode: See ``Configuration options''. LOGO: See ``Status page''. Logo: See ``Configuration options''. logs: See ``Server Log''. MAX_CONNECTION: See ``Status page''. Max_Connection <1>: See ``Configuration options''. Max_Connection: See ``Building an AWS server''. method, dispatcher: See ``Method dispatcher''. MIME: See ``References''. OPENED_V: See ``Status page''. OpenLDAP: See ``Requirements''. OpenSSL: See ``Requirements''. Page server <1>: See ``Static Page server''. Page server: See ``Callback procedure''. pages, split: See ``Split pages''. pages, transient: See ``Transient Pages''. Parameters: See ``Form parameters''. Parameters Get: See ``Form parameters''. Parameters Get_Name: See ``Form parameters''. Payload: See ``Step by step instructions''. PEERNAME_V: See ``Status page''. POP <1>: See ``References''. POP: See ``Retrieving e-mail''. Port: See ``Building an AWS server''. POSIX: See ``Requirements''. Post Office Protocol: See ``Retrieving e-mail''. program_name.ini: See ``Configuration options''. Push: See ``Server Push''. QUIT_V: See ``Status page''. RECEIVE_TIMEOUT: See ``Status page''. Receive_Timeout: See ``Configuration options''. References: See ``References''. Resources: See ``Resources''. resources: See ``Callback procedure''. Retrieving e-mail: See ``Retrieving e-mail''. RFC 0821: See ``References''. RFC 1867: See ``References''. RFC 1939: See ``References''. RFC 1945: See ``References''. RFC 2049: See ``References''. RFC 2109: See ``References''. RFC 2195: See ``References''. RFC 2554: See ``References''. RFC 2616: See ``References''. RFC 2617: See ``References''. Secure server: See ``Secure server''. SECURITY: See ``Status page''. Security: See ``Building an AWS server''. Security_Mode: See ``Configuration options''. Self dependant: See ``Resources''. Send: See ``Server Push''. SEND_TIMEOUT: See ``Status page''. Send_Timeout: See ``Configuration options''. Send_To: See ``Server Push''. Sending e-mail: See ``Sending e-mail''. Sending message: See ``Communication''. Server Push: See ``Server Push''. Server_Host: See ``Configuration options''. SERVER_NAME: See ``Status page''. Server_Name: See ``Configuration options''. SERVER_PORT: See ``Status page''. Server_Port: See ``Configuration options''. SERVER_SOCK: See ``Status page''. Session <1>: See ``Session handling''. Session: See ``Building an AWS server''. SESSION_CLEANUP_INTERVAL: See ``Status page''. Session_Cleanup_Interval (duration): See ``Configuration options''. SESSION_LIFETIME: See ``Status page''. Session_Lifetime (duration): See ``Configuration options''. SESSIONS_TERMINATE_V: See ``Status page''. SESSIONS_TS_V: See ``Status page''. SESSIONS_V: See ``Status page''. Simple Mail Transfer Protocol: See ``Sending e-mail''. Simple Object Access Protocol: See ``Using `SOAP'''. Simple Page server: See ``Static Page server''. Simple server: See ``Callback procedure''. SLOT_ACTIVITY_COUNTER_V: See ``Status page''. SMTP <1>: See ``References''. SMTP: See ``Sending e-mail''. SMTP Authentication: See ``References''. SOAP: See ``Using `SOAP'''. SOAP (API): See ``SOAP''. SOAP 1.1: See ``References''. SOAP Client: See ```SOAP' Client''. SOAP Dispatcher: See ```SOAP' helpers''. SOAP Server: See ```SOAP' Server''. SOAP, dispatcher: See ```SOAP' dispatcher''. SOAP.Client: See ``SOAP.Client''. SOAP.Dispatchers: See ``SOAP.Dispatchers''. SOAP.Dispatchers.Callback <1>: See ``SOAP.Dispatchers.Callback''. SOAP.Dispatchers.Callback: See ```SOAP' helpers''. SOAP.Message: See ``SOAP.Message''. SOAP.Message.XML: See ``SOAP.Message.XML''. SOAP.Parameters: See ``SOAP.Parameters''. SOAP.Types: See ``SOAP.Types''. SOAPAction: See ```SOAP' Server''. SOCK_V: See ``Status page''. socket binding: See ``Requirements''. split pages: See ``Split pages''. SSL <1>: See ``References''. SSL: See ``Protocol''. starting server: See ``Building an AWS server''. Static Page server: See ``Static Page server''. Status: See ``Status page''. STATUS_PAGE: See ``Status page''. Status_Page: See ``Configuration options''. Stream resources: See ``Stream resources''. timer, dispatcher: See ``Timer dispatcher''. TLS: See ``Protocol''. transient pages: See ``Transient Pages''. transient pages, dispatcher: See ``Transient pages dispatcher''. Transient_Cleanup_Interval: See ``Configuration options''. Transient_Lifetime: See ``Configuration options''. Up_Image: See ``Configuration options''. upload, client: See ``Client side''. upload, server: See ``File upload''. UPLOAD_DIRECTORY: See ``Status page''. Upload_Directory: See ``Configuration options''. URI, dispatcher: See ``URI dispatcher''. Using resources: See ``Using resources''. Utils.SOAP_Wrapper: See ```SOAP' helpers''. VALUES_M: See ``Status page''. VERSION: See ``Status page''. virtual host, dispatcher: See ``Virtual host dispatcher''. Web Service Definition Language <1>: See ``Using `WSDL'''. Web Service Definition Language: See ``Using `SOAP'''. Web_Server: See ``Building an AWS server''. Working with Server sockets: See ``Working with Server sockets''. WSDL <1>: See ``Using `WSDL'''. WSDL: See ``Using `SOAP'''. WSDL, Client: See ``Client side (stub)''. WSDL, Server: See ``Server side (skeleton)''. wsdl2aws <1>: See ``wsdl2aws''. wsdl2aws: See ``Using `WSDL'''. wsdl2aws limitations: See ``wsdl2aws limitations''. WWW_Root: See ``Configuration options''.