[fpc-devel] Questions and suggestions to fpWeb

Luiz Americo Pereira Camara luizmed at oi.com.br
Fri Jul 30 17:01:08 CEST 2010


Hi,

I've playing a bit with fpWeb and have some suggestions and questions:

- In TFPWebAction.DoHandleRequest if request is not handled by OnRequest 
and inherited, the content is copied to the response and handled is 
checked by the response content.
  - FContensts will be always created even if is not created previously
  - At this point AResponse.Contents can have some content?
  - If so the handled checking is wrong. See these conditions
     AResponse.Contents.Text <> '';
     Self.Contents.Text = '';
     Handled will be true. Should be false.

 
- Content and Contents properties are redundant. Also can lead to some 
performance issues. See the code of DoGetContent:

    If (Self.Content<>'') then
      Content.Write(Self.Content[1],Length(Self.Content));

Content is computed (Contents items concatenated) three times.

Don't be surprised if users do things like
 
 while  not ready do
  Content := Content + 'xxx';

- TFPWebAction.GetContent is empty. It seems that should call 
TFPWebAction.DoGetContent.
  DoGetContent is inneficient. Cached FContents.Text and and isolated 
string references

- In TCustomFPWebModule.HandleRequest assigned(Session) will always 
evaluate to true (if Session is nil it will be created and then freed 
again).

- It's not necessary to check for nil in SetTemplate
- In the other side a check to nil should be added in SetContents to 
avoid creating FContents

- CGI apps enters in a infinite loop.
Adding

  if FWebHandler.FTerminated then
    Terminate;

to TCustomWebApplication.DoRun fixes it.

Follows patch with my suggestions.

Luiz





-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: fpwebfixes.diff
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20100730/a74c5dab/attachment.ksh>


More information about the fpc-devel mailing list