[Lazarus] New application type: HTTP standalone server
Michael Van Canneyt
michael at freepascal.org
Thu Jun 2 23:27:02 CEST 2011
On Thu, 2 Jun 2011, Leonardo M. Ramé wrote:
> On 2011-06-02 18:30:06 +0200, Michael Van Canneyt wrote:
>> Hi,
>>
>> In revision 31011 I committed support for a HTTP server application in
>> Lazarus, in the lazwebextra package. This is similar in functionality to the
>> embweb package by Joost, but it does not use any external packages: you only
>> need the latest FPC for this (at least rev. 17633).
>>
>> It has an option to be able to serve regular files out-of-the-box. This is
>> implemented as a regular fpWeb HTTP module, which simply sends a file if it
>> finds it. This module is implemented in a (new) unit fpwebfile. It works
>> similar to the Apache server's Alias directive:
>> RegisterFileLocation('files','/some/existing/directory');
>> will map /files/index.html to /some/existing/directory/index.html and send it.
>> Multiple locations can be registered.
>> if a mime.types file is present, the correct content-type is sent.
>>
>> The FPC packages/fcl-web/examples/httpapp directory contains an example of how to use all this.
>>
>> This means that FPC can now be used out of the box to implement web applications/pages
>> as
>> - CGI.
>> - FastCGI.
>> - Apache module.
>> - Standalone webserver.
>> IIS ISAPI support is planned.
>>
>> Comments/suggestions welcome.
>>
>
> Michael, I added a webmodule to testhttp and got two problems.
>
> 1 - Could not determine HTTP module for request "". Even if I call it
> the same way as I use with fpCGI and fpEmbWeb.
That is strange, because it works fine here ?
Can you send a test program please ? (in private) then I will test.
Did you test the sample program ? Does it happen there too ?
>
> 2 - The 2nd time I run the program I get. ESocketError "Binding of
> socket failed: 8080".
Yes. This can happen sometimes, and it is normal.
You need to wait till the kernel releases the address again.
Waiting 20 seconds is usually enough. (I agree it is annoying ;) )
It is on my todo list to add setsocketopt(SO_REUSEADDR) support to ssockets.
This will remedy the problem. I will try to do it this weekend.
> I'm running Ubuntu 11.04 - 64bits.
Good choice. I run the same system ;-)
Michael.
More information about the Lazarus
mailing list