Hi,

I have problem using the above function in unicode compiler
Just tried to include a content of a file to "servertime" document

The content of header.html:
<div id="header">
  Some headerline 1</br>
  Some headerline 2</br>
  Some headerline 3</br>
</div>

and the result is:

<HTML><HEAD><TITLE>ICS WebServer Demo</TITLE></HEAD>
<BODY>???????????????????????????????????????????????????? eaderline
2</br> Some headerline 3</br> </div> <H2>Time at server side:</H2>
<P>2011.01.24. 18:35:17</P> <A HREF="/demo.html">Demo menu</A>
</BODY></HTML>



{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *}
{ This procedure is use to generate /time.html
document                     }
procedure TWebServForm.CreateVirtualDocument_Time(
    Sender    : TObject;            { HTTP server
component                 }
    ClientCnx : TMyHttpConnection;  { Client connection issuing
command     }
    var Flags : THttpGetFlag);      { Tells what HTTP server has to do
next }

var
  HeaderString:String;
begin
    HeaderString :=
ClientCnx.HtmlPageProducerToString('header.html',nil,[]);
    ClientCnx.AnswerString(Flags,
        '',                            { Default Status '200
OK'            }
        '',                            { Default Content-Type:
text/html    }
        'Pragma: no-cache' + #13#10 +  { No client caching
please           }
        'Expires: -1'      + #13#10,   { I said: no caching
!               }
        '<HTML>' +
          '<HEAD>' +
            '<TITLE>ICS WebServer Demo</TITLE>' +
          '</HEAD>' + #13#10 +
          '<BODY>' +  HeaderString +
            '<H2>Time at server side:</H2>' + #13#10 +
            '<P>' + DateTimeToStr(Now) +'</P>' + #13#10 +
            '<A HREF="/demo.html">Demo menu</A>' + #13#10 +
          '</BODY>' +
        '</HTML>');
end;



{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *}
function THttpConnection.HtmlPageProducerToString(
    const HtmlFile : String;
    UserData       : TObject;
    Tags           : array of const) : String;
var
    Stream : TMemoryStream;
begin
    Stream := TMemoryStream.Create;
    try
        HtmlPageProducerToStream(HtmlFile, UserData, Tags, Stream);
        SetLength(Result, Stream.Size);
        Stream.Seek(0, 0);

If I save the stream to a file: Stream.SaveToFile('teszt.html')
the file contains the expected data.

        Stream.Read(Result[1], Stream.Size);

Here Result contains garbage.

    finally
        Stream.Free;
    end;
end;

Regards
Peter
A(z) kimenő üzenetben nem található vírus.
Ellenőrizte: AVG - www.avg.com
Verzió: 9.0.872 / Vírus adatbázis: 271.1.1/3400 - Kiadás dátuma: 01/24/11 
08:35:00
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to