Http server
The http server in eClever supports multiusers applications, games and
other applications that need to be preferably built using an http protocol based
communication, rather than using a socket server. In many cases the socket server
and http server will complement each other. You can send commands to the http server
using the methods GET or POST. To call the server you have to use the parameter
action in which you define the function you want to be executed by the http server.
The functions will be separately explained in the following text. This http server
is not a replacement of commercial servers for www applications. It is rather a
support of socket server in the case we need an http communication.
Calling of http server using the method GET
http://ip-adresa:port/?action=function¶m1=value1¶m2=value2....¶mX=valueX
where ip and port are parameters defined in eClever.config in the section http-server/connections.
Note. Every calling of http Server can have many parameters. Only one of them is
compulsory being the parameter action.
Example
http://127.0.0.1:2722?action=cross-domain-policy.
Calling of http server using the method POST:http://ip-adresa:port/
The same as for the method GET is valid for the method POST too. The only difference
is that the parameters are not part of the address as they have to be defined corresponding
to the method POST.
Example
http://127.0.0.1:2722/
You can test all the functions called using the method GET in a normal Internet
browser. In the functions that need insertion of special characters in their parameters,
such as xml documents, the method GET cannot be used, only the POST one. This will
be mentioned for every function separately.
Error return
If any error occurs in the http server, it return an xml document in the following
shape:
<?xml version="1.0" encoding="utf-8"?>
<results>
<status errorCode="-1"/>
</results>
where errorCode is number of the error.
The following table shows a list of common errors, that the http server returns
to the client.
errorCode |
|
Error description |
-1 |
|
The http server does not know the function defined in the parameter action. |
-2 |
|
You are using an unregistered version of the XMl Socket Multiuser Serveru - eClever,
consequently the http server will only allow execution of 50 http commands. |
-3 |
|
IP address of client is placed in section black-list of eClever.config. |
-4 |
|
IP address of client is not placed in section white-list of eClever.config. |
Other errors will be defined separately for the appropriate function.
Working with files
The functions returning files located on the server use the parameter file.
Example of calling a function using the method GET
http://127.0.0.1:2722?action=gettxt&file=abc.txt&user=john&password=d27B48
As the default directory will be used the one set in the attribute root in section
http-server. The returned folders are derived from this folder. If, for example,
the folder c:\eclever\http\ is defined in the attribute root and in the parameter
file we insert the file chat\ekology\doc1.xml, the http server will look for this
file in the directory c:\eclever\http\chat\ekology\.
If one wants to secure the file in a directory we have to put the xml file eclever.auth
to it. Its structure will be:
<?xml version="1.0" encoding="utf-8"?>
<folder>
<authentication user="abc" password="aa2"/>
</folder>
where user and password are access data for the given directory.
In the parameters of the http query we have to insert parameters user and password
that must be identical with the parameters of the same names in eclever.auth. If
in a directory the file eclever.auth is not placed we do not have to use the parameters
user and password in http query.
Errors that can occur during reading of files from the server.
errorCode |
|
Error description |
10 |
|
The directory defined in eClever.config does not exist. |
11 |
|
The file defined in the parameter file does not exist. |
12 |
|
The suffix of the file does not correspond to the selection action. |
13 |
|
The returned file is of a larger size than allowed in the attribute maxDocLength. |
14 |
|
The directory is secured by the file eClever.auth and in parameters of the http
query valid values for user and password are not entered. |
Actions used by http server
The function returns an xml document defined in the section cross-domain-policy in policy.config.
The function returns txt file placed on the server.
The function returns xml file placed on the server.
The function returns css file placed on the server.
The function returns htm or html file placed on the server.
The function returns jpg or jpeg file placed on the server.
The function returns gif file placed on the server.
The function returns png file placed on the server.
The function returns swf file placed on the server (Flash, Flex etc.).
The function returns dir file placed on the server (Director).
The function returns dxr file placed on the server (Director).
The function returns dcr file placed on the server (Director).
The function returns cst file placed on the server (Director).
The function returns cxt file placed on the server (Director).
The function returns zip file placed on the server.
The function returns rtf file placed on the server.
The function returns mpeg file placed on the server.
The function returns avi file placed on the server.
The function returns mp3 file placed on the server.
The function returns flv file placed on the server.