Re: [twsocket] Creating a TSslWebAppSrv component

2011-11-28 Thread Busai Péter
What do you mean "not nice"? This is the whole point of OOP. :)

Actually it is not that simple. I don't want to put TSslHttpAppSrv in
the original unit of THttpAppSrv because SVN will complain every time I
do a check-out.
I tried to put it in a new unit, however it seems THttpAppSrv and
TUrlHandler are "friends". Code in HttpAppSrv accessing protected
variables in UrlHandler. So do I have to dup TUrlHandler as well ?

Regards
Peter

>> Hi,
>> I wonder what is the proper way,
>> to derive from TSslHttpServer and copy all the AppServer stuff
>> or to derive from THttpAppSrv and add the SSL stuff?
> It's likely the easiest approach to derive THttpAppSrv from
> THttpsServer rather than from THttpServer (untested).
> This required change of one single line in source code, not nice,
> however should work. 
>
--
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


[twsocket] Creating a TSslWebAppSrv component

2011-11-27 Thread Busai Péter
Hi,
I wonder what is the proper way,
to derive from TSslHttpServer and copy all the AppServer stuff
or to derive from THttpAppSrv and add the SSL stuff?

Regards
Peter

--
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


Re: [twsocket] Evaluating TOverbyteIcsSysLogServer

2011-11-11 Thread Busai Péter



Hello Peter,

Thanks for your feedback. While you are at it, maybe you could fix the 
issues you see and propose it to the community ?
Before doing that, be sure to download the very latest development 
snapshot, preferably directly out of the SVN repository. Then make 
your changes and submit a SVN diff file.


Regards,
--
francois.pie...@overbyte.be


Sure

Just an other question.
Sample from Memo output:
   TimeStamp= 2011-11-11T11:45:48.000+01:00
   DateTime = 2011-11-11 11:45:48.000

Shouldnt DecodedMessage.Hour be corrected by DecodedMessage.TZBias ?

Checked out latest SVN today. Revision 818.

In case attachment does not go through.

OverbyteIcsSysLogServer.diff:
--- 
C:/DOCUME~1/Peter/LOCALS~1/Temp/OverbyteIcsSysLogServer.pas-revBASE.svn000.tmp.pas
P nov. 11 12:13:37 2011
+++ C:/delphi/ics_svn/trunk/Delphi/Vc32/OverbyteIcsSysLogServer.pasP 
nov. 11 11:40:36 2011

@@ -198,7 +198,7 @@
((RawMessage[Index] >= 'A') and (RawMessage[Index] <= 'Z')) or
((RawMessage[Index] >= 'a') and (RawMessage[Index] <= 'z')) or
((RawMessage[Index] >= '0') and (RawMessage[Index] <= '9')) or
-(RawMessage[Index]  = '.') or
+(RawMessage[Index]  = '.') or (RawMessage[Index]  = '-') or
 (RawMessage[Index]  = '_')
   ) do
 Inc(Index);
@@ -455,6 +455,15 @@
 SMSec := '0';
 end;

+SMsec := '0' + DecimalSeparator + SMSec;
+DecodedMessage.Year := StrToInt(SYear);
+DecodedMessage.Month:= StrToInt(SMonth);
+DecodedMessage.Day  := StrToInt(SDay);
+DecodedMessage.Hour := StrToInt(SHour);
+DecodedMessage.Minute   := StrToInt(SMinute);
+DecodedMessage.Second   := StrToInt(SSecond);
+DecodedMessage.MilliSec := Trunc(1000 * StrToFloat(SMsec));
+
 case Delim of
 'Z', ' ' : DecodedMessage.TZBias := 0;
 '+', '-' :
@@ -486,14 +495,6 @@
   String(RawMessage) + '"');
 end;

-SMsec := '0' + DecimalSeparator + SMSec;
-DecodedMessage.Year := StrToInt(SYear);
-DecodedMessage.Month:= StrToInt(SMonth);
-DecodedMessage.Day  := StrToInt(SDay);
-DecodedMessage.Hour := StrToInt(SHour);
-DecodedMessage.Minute   := StrToInt(SMinute);
-DecodedMessage.Second   := StrToInt(SSecond);
-DecodedMessage.MilliSec := Trunc(1000 * StrToFloat(SMsec));
 DecodedMessage.TimeString := String(Copy(RawMessage, Index1, Index 
- Index1));


 if (Index > Length(RawMessage)) or



OverbyteIcsSysLogServerDemo.pas.diff:
--- 
C:/DOCUME~1/Peter/LOCALS~1/Temp/OverbyteIcsSysLogServerDemo1.pas-revBASE.svn000.tmp.pas
P nov. 11 12:16:39 2011
+++ 
C:/delphi/ics_svn/trunk/Delphi/Internet/OverbyteIcsSysLogServerDemo1.pas
P nov. 11 11:15:16 2011

@@ -53,16 +53,19 @@
 ToolsPanel: TPanel;
 DisplayMemo: TMemo;
 StartButton: TButton;
+StopButton: TButton;
 procedure FormShow(Sender: TObject);
 procedure FormClose(Sender: TObject; var Action: TCloseAction);
 procedure FormCreate(Sender: TObject);
 procedure StartButtonClick(Sender: TObject);
 procedure SysLogServer1DataAvailable(Sender: TObject; const SrcIP, 
SrcPort,

   RawMessage: AnsiString);
+procedure StopButtonClick(Sender: TObject);
   private
 FIniFileName : String;
 FInitialized : Boolean;
 FSysLogServer: TSysLogServer;
+procedure SetButtons(Listening:Boolean);
   public
 procedure Display(Msg : String);
 property IniFileName : String read FIniFileName write FIniFileName;
@@ -89,6 +92,7 @@
 FSysLogServer := TSysLogServer.Create(Self);
 FIniFileName := OverbyteIcsIniFiles.GetIcsIniFileName;
 DisplayMemo.Clear;
+FSysLogServer.OnDataAvailable := SysLogServer1DataAvailable;
 end;


@@ -150,14 +154,27 @@
 end;
 end;

+procedure TSysLogServerForm.SetButtons(Listening:Boolean);
+begin
+  StartButton.Enabled := not Listening;
+  StopButton.Enabled  := Listening;
+end;

+
 {* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
* * *}

 procedure TSysLogServerForm.StartButtonClick(Sender: TObject);
 begin
 FSysLogServer.Listen;
+SetButtons(TRUE);
 end;


+procedure TSysLogServerForm.StopButtonClick(Sender: TObject);
+begin
+FSysLogServer.Close;
+SetButtons(FALSE);
+end;
+
 {* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
* * *}

 procedure TSysLogServerForm.SysLogServer1DataAvailable(
 Sender: TObject;


OverbyteIcsSysLogServerDemo.dfm.diff:
--- 
C:/DOCUME~1/Peter/LOCALS~1/Temp/OverbyteIcsSysLogServerDemo1.dfm-revBASE.svn000.tmp.dfm
P nov. 11 12:18:13 2011
+++ 
C:/delphi/ics_svn/trunk/Delphi/Internet/OverbyteIcsSysLogServerDemo1.dfm
P nov. 11 11:15:00 2011

@@ -1,9 +1,9 @@
 object SysLogServerForm: TSysLogServerForm
   Left = 70
   Top = 187
-  Width = 379
-  Height = 247
   Caption = 'SysLogServer - http://www.overbyte.be'
+  ClientHeight = 220
+  ClientWidth = 371
   Color = clBtnFace
   Font.Charset = DEFAULT_CHARSET
   Font.Co

Re: [twsocket] Evaluating TOverbyteIcsSysLogServer

2011-11-11 Thread Busai Péter


If client hostname contains negative sign "-" , for example 
"somename-peter", than between lines 520-532 it is evaluated as 
"invalid PID delimter" and an exception is raised.

I dont know if this is a valid hostname for that RFC

Some digging in the RFCs:

http://tools.ietf.org/html/rfc5424#page-13

 "The HOSTNAME field SHOULD contain the hostname and the domain name of
   the originator in the format specified in STD 13 [RFC1034  
]"

According to RFC1034 a hypen is a valid character.
http://tools.ietf.org/html/rfc1034 Page 10.

IMHO unit OverbyteIcsSysLogServer.pas function GetWord should also check 
for hypen-minus "-" character


Regards
Peter
--
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


[twsocket] Evaluating TOverbyteIcsSysLogServer

2011-11-11 Thread Busai Péter

Hi,

Some bugs:

OverbyteIcsSysLogServerDemo:
FSysLogServer component is created runtime on form creation, but 
SysLogServer1DataAvailable method is not assigned to 
FSysLogServer.OnDataAvailable anywhere.


TSysLogServer.ParseRawMessageRFC5424:
From line 400 to 457 Date and Time values are read from message 
respectively to SYear, SMonth,SDay,SHour,SMinute,SSecond and SMSec
but if there is a Time Bias, SHour,SMinute are owerritten is case 
construct (Line 463,471)
After case construct in line 493,494 DecodedMessage.Hour and 
DecodedMessage.Minute will get values from the overwritten variables.


If client hostname contains negative sign "-" , for example 
"somename-peter", than between lines 520-532 it is evaluated as "invalid 
PID delimter" and an exception is raised.

I dont know if this is a valid hostname for that RFC

Regards
Peter


--
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


Re: [twsocket] Problem with UTF8 and Thttpappserv

2011-03-10 Thread Busai Péter

FileCodepage is to tell the component the encoding of template file.
DstCodepage is for the result.
You can have a template file in different encoding than you want the result.

Peter



Hi Arno,

yeees great, That works. I've tried with different languages (polish,german 
...) and it is ok, but one question left: for what are the 2 parameters 
(FileCodepage/DstCodepage)?

Best regards,
Stefan


--
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


Re: [twsocket] Webapp pulldown list

2011-02-18 Thread Busai Péter
Or using javascript it could be possible to change form's "action" value
dinamically to the selected option link and submit a simple get.
Hmm, using onChange and javascipt you dont even need a form.
But than it is OT here.

> As Francois suggested, embedd select in a form and add define onchange
> event to select.
> 
> 
> 
> 
>
> In URLHandlerSomething do a relocation to the posted link
>
> Peter
>
>> The code I had was for a table, giving 'hyperlinks' to the items.
>>
>> 
>> Satellite-name
>> <#table_rows  SatList>
>> <#SAT>
>> 
>> 
>>
>> So when i select my 'value' in the pulldown, it needs to open the link
>> satlist?CUS=<#CUS>&SATNAME=<#SAT>
>>
>> Ruud Kerstens
>>
>> Op 18-2-2011 11:11, Francois PIETTE schreef:
 Is there a way to activate the link in the pulldown after selecting it?
>>> Sorry, I don't understand the question.
>>> Maybe you want to make the pulldown par of a html form. Just give a
>>> name attribute to the select tag and it will be sent as a field when
>>> the form is submitted. Your Delphi code can then grab the value of
>>> the selected option as any other form variable.
>>>
>>> -- 
>>> francois.pie...@overbyte.be
>>> The author of the freeware multi-tier middleware MidWare
>>> The author of the freeware Internet Component Suite (ICS)
>>> http://www.overbyte.be 
--
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


Re: [twsocket] Webapp pulldown list

2011-02-18 Thread Busai Péter
As Francois suggested, embedd select in a form and add define onchange
event to select.





In URLHandlerSomething do a relocation to the posted link

Peter

> The code I had was for a table, giving 'hyperlinks' to the items.
>
> 
> Satellite-name
> <#table_rows  SatList>
> <#SAT>
> 
> 
>
> So when i select my 'value' in the pulldown, it needs to open the link
> satlist?CUS=<#CUS>&SATNAME=<#SAT>
>
> Ruud Kerstens
>
> Op 18-2-2011 11:11, Francois PIETTE schreef:
>>> Is there a way to activate the link in the pulldown after selecting it?
>>
>> Sorry, I don't understand the question.
>> Maybe you want to make the pulldown par of a html form. Just give a
>> name attribute to the select tag and it will be sent as a field when
>> the form is submitted. Your Delphi code can then grab the value of
>> the selected option as any other form variable.
>>
>> -- 
>> francois.pie...@overbyte.be
>> The author of the freeware multi-tier middleware MidWare
>> The author of the freeware Internet Component Suite (ICS)
>> http://www.overbyte.be 
>
--
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


Re: [twsocket] HttpAppServer Finish question

2011-01-30 Thread Busai Péter
Thanks.
I send answer and call Finish in OnTerminate event.
AFAIK that runs in main thread context.

Peter

2011.01.30. 15:51 keltezéssel, Francois PIETTE írta:
> You have to call Finish in the contrext of the thread running
> UrlHandler.Execute, not your worker thread. It is not important that
> it is in the Execute method, only the thread context matters.
>
> Of course, the browser has a timeout, but much longer than 10 seconds.
>
--
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


[twsocket] HttpAppServer Finish question

2011-01-30 Thread Busai Péter
Hi,

What exactly is it doing?

If  I have to use a worker thread to run long queries, I create thread
in the URLHandler.
Pass connection parameters to thread and prepare answer  in Threads
execute method.
Then send answer in UrlHandler.FinishThread event.
Should I call Finish at end of URLHandler.Execute, or at end of thread
in UrlHandler.FinishThread event?
In later case, in my experience, if thread runs more than 10secs (fx.
calling sleep(11000) in thread),
connection state is changed from wsConnected to wsOpened and I can not
send answer.
The browser shows a blank screen and says ready (Firefox).
Does this timeout has something to do with calling Finish or not?

Thanks
Peter



--
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


Re: [twsocket] Another unicode issue

2011-01-28 Thread Busai Péter



I just checked in the change. If you use SVN you should revert previous
changes before update in order to avoid conflicts,

"Resolve conflicts using 'theirs'" is just one click ;)

Peter
--
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


Re: [twsocket] Another unicode issue

2011-01-28 Thread Busai Péter

Sorry, they must be surrounded by defines to work in older compilers:

HandleTableRow(TagParams, P + J + 1, Q - P - J - 1,
   RowDataGetter, UserData, DestStream
   {$IFDEF COMPILER12_UP}
   , DestCodePage
   {$ENDIF}
   );

StreamWriteStrA(DestStream, TagValue
   {$IFDEF COMPILER12_UP}
   ,DestCodePage
   {$ENDIF}
   );


Peter

2011.01.27. 21:35 keltezéssel, Busai Péter írta:

Hi Arno,

There were two DestCodePage parameter passover missing in
OverbyteIcsHttpSrv.

function HtmlPageProducerFromMemory
Line: 5068
 HandleTableRow(TagParams, P + J + 1, Q - P - J - 1,
RowDataGetter, UserData, DestStream,
DestCodePage);

and

Line: 5076
 StreamWriteStrA(DestStream, TagValue, DestCodePage);



--
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


Re: [twsocket] Another unicode issue

2011-01-27 Thread Busai Péter
Hi Arno,

There were two DestCodePage parameter passover missing in
OverbyteIcsHttpSrv.

function HtmlPageProducerFromMemory
Line: 5068
HandleTableRow(TagParams, P + J + 1, Q - P - J - 1,
   RowDataGetter, UserData, DestStream,
DestCodePage);

and

Line: 5076
StreamWriteStrA(DestStream, TagValue, DestCodePage);

Now it seems to work as expected.
I just tried UTF8
I have template file in UTF8 format and I need UTF8 encoded results.
With these two corrections Tag values are also converted.

It seems vtWideChar problem solved also.
I tested on Delphi XE, but had no time to test it on ansi compiler.

Thank you very much

Peter

2011.01.27. 18:22 keltezéssel, Arno Garrels írta:
> Arno Garrels wrote:
>> Busai Péter wrote:
>>> In HttpAppServer, URLHandler
>>>
>>> Call
>>> Client.AnswerPage(Flags,'','','template.html',nil,['SOMEKEY','A']);
>>>
>>> The value of SOMEKEY must be one character long.
>>>
>>> Result rendered in html page:
>>> Unsupported TVarRec.VType = vtWideChar
>> I uploaded changed versions of OverbyteIcsHttpSrv.pas and
>> OverbyteIcsHttpAppServer.pas here:
>> http://www.duodata.de/misc/delphi/ics/OverbyteIcsHttpSrv733.zip
>>
>> Fixed VarRecToString. AnswerPage and other functions take
>> optional codepage parameters now, you asked that some days back.
>> So it should now be possible to write i.e. UTF-8 encoded HTML
>> by passing CP_UTF8 in parameter DstCodePage, the default is
>> CP_ACP. Since it's not much tested please give it a trial and
>> let me know how it works for you before I upload this change to
>> the repository.
> Just in case you downloaded the wrong ZIP, VarRecToString should
> look like:
>
> function VarRecToString(V : TVarRec) : String;
> const
> BooleanToString : array [Boolean] of String = ('FALSE', 'TRUE');
> begin
> case V.VType of
> vtInteger:Result := _IntToStr(V.VInteger);
> vtBoolean:Result := BooleanToString[V.VBoolean];
> vtChar:   Result := String(V.VChar);
> vtExtended:   Result := _FloatToStr(V.VExtended^);
> vtString: Result := String(V.VString^);
> vtPointer:Result := 'Unsupported TVarRec.VType = vtPointer';
> vtPChar:  Result := String(_StrPas(V.VPChar));
> vtObject: Result := 'Unsupported TVarRec.VType = vtObject';
> vtClass:  Result := 'Unsupported TVarRec.VType = vtClass';
> vtWideChar:   Result := String(V.VWideChar);
> vtPWideChar:  Result := String(V.VPWideChar);
> vtAnsiString: Result := String(_StrPas(V.VPChar));
> vtCurrency:   Result := 'Unsupported TVarRec.VType = vtCurrency';
> vtVariant:Result := 'Unsupported TVarRec.VType = vtVariant';
> vtWideString: Result := 'Unsupported TVarRec.VType = vtWideString';
> vtInterface:  Result := 'Unsupported TVarRec.VType = vtInterface';
> vtInt64:  Result := _IntToStr(V.VInt64^);
> {$IFDEF COMPILER12_UP}
> vtUnicodeString:  Result := PWideChar(V.VUnicodeString);
> {$ENDIF}
> else
> Result := 'Unknown TVarRec.VType = "' + _IntToStr(Ord(V.VType)) + '" 
> ';
> end;
>
> //OutputDebugString(PChar('VarRecToString ' + Result));
> end;
>
--
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


[twsocket] Another unicode issue

2011-01-26 Thread Busai Péter
In HttpAppServer, URLHandler

Call Client.AnswerPage(Flags,'','','template.html',nil,['SOMEKEY','A']);

The value of SOMEKEY must be one character long.

Result rendered in html page:
Unsupported TVarRec.VType = vtWideChar


Steps to reproduce in demo:
Modify TUrlHandlerHomePageHtml to pass just one character for 'LOGIN'


procedure TUrlHandlerHomePageHtml.Execute;
begin
if NotLogged then
Exit;
AnswerPage('', NO_CACHE, '/HomePage.html', nil,
-->   ['LOGIN',   'Q', //UrlLogin,
'COUNTER', UrlCounter,
'CONFIG',  UrlConfigForm,
'COUNTERVIEW', UrlCounterViewHtml,
'USERCODE',SessionData.UserCode,
'LOGINTIME',   DateToStr(SessionData.LogonTime)]);
Finish;
end;



Result:
...
Counter view (AJAX)
Send Email Form

Your are not demo ? Change user.


...



Peter

--
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


Re: [twsocket] sending jpg through httpserver

2011-01-26 Thread Busai Péter
Hi Edwin,

AnswerStream is just perfect for that.
Here is how I send png. It is stored in FpngStream, which is also a
TMemoryStream.
I dont want it to be destroyed after sent. That is why I create an other
memory stream and copy
then content.

ClientCnx.DocStream := TMemoryStream.Create;
ClientCnx.DocStream.CopyFrom(TSessionData(SessionList[index]).FpngStream,0);
ClientCnx.AnswerStream(Flags,'','image/png','');

Peter

2011.01.26. 22:53 keltezéssel, Edwin @ Clanhay írta:
> I am trying to send a jpg from delphi's tjpgImage to a client with the 
> tHTTPServer component.
> Would like to keep it in a memory stream and not save to disk, but 
> AnswerStream is not what it sounds like.
> Searched the archives but found little that was close to what I wanted.
> Still using ICS 5.
>
> Any ideas?
>
> ed
>
--
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


Re: [twsocket] HttpAppServer, how to alter client.path

2011-01-26 Thread Busai Péter
Ok, it is working now.
Just some missing slashes in path caused trouble.

Peter


> I found "AddGetAllowedPath" in demo project.
> Is that something to to do with this?
> What is it doing?
> Not much comment about it in the source.
>
> Peter
>
--
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


Re: [twsocket] HttpAppServer, how to alter client.path

2011-01-26 Thread Busai Péter
I found "AddGetAllowedPath" in demo project.
Is that something to to do with this?
What is it doing?
Not much comment about it in the source.

Peter

> Hi,
>
> I'm trying to create "nested" virtual document names like for example:
> /Admin/Serverinfo
> I created an URLHandler for that
> HttpAppSrv.AddGetHandler('/Admin/ServerInfo', TUrlHandlerAdmin);
> Images for web page are contained in {docroot}/images directory
> In the template document I use relative path to images etc...
> But this way the browser requests images from {webroot}/Admin/images/...
>
> Is there a way to rewrite path, to get images from directory one level up?
> Or should I forget those fancy URLs?
>
--
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


[twsocket] HttpAppServer, how to alter client.path

2011-01-26 Thread Busai Péter
Hi,

I'm trying to create "nested" virtual document names like for example:
/Admin/Serverinfo
I created an URLHandler for that
HttpAppSrv.AddGetHandler('/Admin/ServerInfo', TUrlHandlerAdmin);
Images for web page are contained in {docroot}/images directory
In the template document I use relative path to images etc...
But this way the browser requests images from {webroot}/Admin/images/...

Is there a way to rewrite path, to get images from directory one level up?
Or should I forget those fancy URLs?

Thanks
Peter
--
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


Re: [twsocket] HtmlPageProducerToString in Delphi XE

2011-01-25 Thread Busai Péter
Hi Francois,

Yes it works fine.
Thanks!


Peter



2011.01.25. 9:27 keltezéssel, Francois PIETTE írta:
> Hello Péter,
>
> Thanks for your help.
> I have updated the source code as follow. Please check if this works
> for you before I commit the change to the repository.
>
> function THttpConnection.HtmlPageProducerToString(
>const HtmlFile : String;
>UserData   : TObject;
>Tags   : array of const) : String;
> var
>Stream : TMemoryStream;
> const
>NulByte : Byte = 0;
> begin
>Stream := TMemoryStream.Create;
>try
>HtmlPageProducerToStream(HtmlFile, UserData, Tags, Stream);
> {$IFDEf COMPILER12_UP}
>// For unicode char compiler (D2009 and up)
>// Add a nul byte at the end of string
>Stream.Write(NulByte, 1);
>Result := String(PAnsiChar(Stream.Memory));
> {$ELSE}
>// For ansi char compiler
>SetLength(Result, Stream.Size);
>Stream.Seek(0, 0);
>Stream.Read(Result[1], Stream.Size);
> {$ENDIF}
>finally
>Stream.Free;
>end;
> end;
>
> -- 
> francois.pie...@overbyte.be
> The author of the freeware multi-tier middleware MidWare
> The author of the freeware Internet Component Suite (ICS)
> http://www.overbyte.be
>
--
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


Re: [twsocket] HtmlPageProducerToString in Delphi XE

2011-01-24 Thread Busai Péter
One possible solution, I defined a temporary RawByteString and now it
returns correct result.
I have tested it on DelphiXE and BDS2006.

{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *}
function THttpConnection.HtmlPageProducerToString(
const HtmlFile : String;
UserData   : TObject;
Tags   : array of const) : String;
var
Stream : TMemoryStream;
{$IFDEF COMPILER12_UP}
S : RawByteString;
{$ELSE}
S : String;
{$END}
begin
Stream := TMemoryStream.Create;
try
HtmlPageProducerToStream(HtmlFile, UserData, Tags, Stream);
SetLength(S, Stream.Size);
Stream.Seek(0, 0);
Stream.Read(S[1], Stream.Size);
Result := S;
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

Re: [twsocket] HtmlPageProducerToString in Delphi XE

2011-01-24 Thread Busai Péter
For a fast workaround now I use TStringStream

  HeaderStream := TStringStream.Create;
  try
Client.HtmlPageProducerToStream('header.html',nil,[
  'LOCATION', SessionData.Referer,
 
'ISADMIN',IfThen(SessionData.IsAdmin,'','style="display:none;"')
  ],HeaderStream);
AnswerPage('','','home.html',nil,[
  'HEADER',UTF8Encode(HeaderStream.DataString)
...

Peter


2011.01.24. 18:42 keltezéssel, Busai Péter írta:
> 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:
> 
>   Some headerline 1
>   Some headerline 2
>   Some headerline 3
> 
>
> and the result is:
>
> ICS WebServer Demo
>  eaderline
> 2 Some headerline 3  Time at server side:
> 2011.01.24. 18:35:17 Demo menu
> 
>
>
>
> {* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
> * *}
> { 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
> !   }
> '' +
>   '' +
> 'ICS WebServer Demo' +
>   '' + #13#10 +
>   '' +  HeaderString +
> 'Time at server side:' + #13#10 +
> '' + DateTimeToStr(Now) +'' + #13#10 +
> 'Demo menu' + #13#10 +
>   '' +
> '');
> 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
>
>
> --
> 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
>
>
>
> A(z) bejövő ü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
>
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

[twsocket] HtmlPageProducerToString in Delphi XE

2011-01-24 Thread Busai Péter
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:

  Some headerline 1
  Some headerline 2
  Some headerline 3


and the result is:

ICS WebServer Demo
 eaderline
2 Some headerline 3  Time at server side:
2011.01.24. 18:35:17 Demo menu




{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *}
{ 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
!   }
'' +
  '' +
'ICS WebServer Demo' +
  '' + #13#10 +
  '' +  HeaderString +
'Time at server side:' + #13#10 +
'' + DateTimeToStr(Now) +'' + #13#10 +
'Demo menu' + #13#10 +
  '' +
'');
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

[twsocket] HttpServer UTF8 problem

2011-01-09 Thread Busai Péter
Hi!

I'm trying to port my webapplication to Delphi XE unicode compiler.
I have problem to encode accented text in RowDataGetter.
In recent nonunicode version I just made conversion like:
Tagdata.Add('key', AnsiToUTF8(some_accented_value))
In Delphi XE I tried Tagdata.Add('key',
UTF8Encode(some_accented_value)), but the result is not UTF8 encoded.
I think it is converted back to Unicode because Add accepts String
parameters.
Where and how should I do the conversion?

Thanks
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/3368 - Kiadás dátuma: 01/08/11 
20:34: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

Re: [twsocket] Using FTPClient in dll

2010-12-01 Thread Busai Péter

2010.12.01. 7:07 keltezéssel, Arno Garrels írta:


That's true, you should not call ProcessMessages in a loop like
above. NOFORMS and MessageLoop should work. Otherwise show us some
more of your code.


Again you are right. NOFORMS is the key.
The below comment from OverbyteIcsDll1.dpr was a bit misleading.
"{$DEFINE NOFORMS}   // This will avoid forms unit and reduce DLL size"
I deleted that line because I knew I have to use forms unit in one of my 
units.

Now I see that it is explained in wsocket.pas history.

Thanks.
--
Peter
--
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


Re: [twsocket] Using FTPClient in dll

2010-11-30 Thread Busai Péter



2010.11.30. 20:41 keltezéssel, Arno Garrels írta:



Well, I do not clearly understand the internals, but defining NOFORMS
in project option
and  using
 while not FTPCli.Terminated do
   FTPCli.ProcessMessages;

instead of

   FTPCli.MessageLoop

and quitting with FTPCli.PostQuitMessage did work.

You must be using some current ICS version. That's positive
feedback! PostQuitMessage was introduced recently to ease quit
of the message loop.


My first thing was to update from svn ;)
However I think the above design not very nice, since CPU is on 100% 
while transfer is taking place.


--
Peter
--
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


Re: [twsocket] Using FTPClient in dll

2010-11-30 Thread Busai Péter



Solved.

That's great, please describe briefly the cause of the problem
and how it was solved, readers of this list might benefit from
your findings and save some time.



Well, I do not clearly understand the internals, but defining NOFORMS in 
project option

and  using
while not FTPCli.Terminated do
  FTPCli.ProcessMessages;

instead of

  FTPCli.MessageLoop

and quitting with FTPCli.PostQuitMessage did work.

--
Peter
--
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


Re: [twsocket] Using FTPClient in dll

2010-11-30 Thread Busai Péter

Solved.




Hi!

I have to write a dll which downloads some file.
I created a project using example "OverbyteIcsDll2.dpr" as a sample.
There are 2 differences. I must put a form inside the dll, which is just
a user interface to set up and save connection parameters, but this form
is not
created at the time of transfer. So NOFORMS is not defined.
The other difference is that I create a datamodule in the thread, and
ftpcli is created inside that module.
I use async methods.
It is started from a method of datamodule:
   FTPCli.OpenAsync;
   FTPCli.MessageLoop;

The transfer is working fine.
The problem is, when OnSessionClosed is fired, PostMessage sends WM_QUIT
to FTPCli.Handle* but MessageLoop does not exit.

* Also tried FtpCli.ControlSocket.Handle and FtpCli.WndHandler.Handle

What am I missing?
Thank in advance.

Peter


--
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


[twsocket] Using FTPClient in dll

2010-11-29 Thread Busai Péter
Hi!

I have to write a dll which downloads some file.
I created a project using example "OverbyteIcsDll2.dpr" as a sample.
There are 2 differences. I must put a form inside the dll, which is just
a user interface to set up and save connection parameters, but this form
is not
created at the time of transfer. So NOFORMS is not defined.
The other difference is that I create a datamodule in the thread, and
ftpcli is created inside that module.
I use async methods.
It is started from a method of datamodule:
  FTPCli.OpenAsync;
  FTPCli.MessageLoop;

The transfer is working fine.
The problem is, when OnSessionClosed is fired, PostMessage sends WM_QUIT
to FTPCli.Handle* but MessageLoop does not exit.

* Also tried FtpCli.ControlSocket.Handle and FtpCli.WndHandler.Handle

What am I missing?
Thank in advance.

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/3287 - Kiadás dátuma: 11/29/10 
08:34: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

Re: [twsocket] FTPServer access violation

2010-03-15 Thread Busai Péter
I use BDS2006.
After playing around with project options (optimization,etc...) the
error wanished.
I can not reproduce it now. May be it was some caching problem of the
compiler.
Thanks
Peter

2010.03.15. 9:08 keltezéssel, Angus Robertson - Magenta Systems Ltd írta:
>> I'm testing ICS V7 FTP server demo from latest SVN checkout. I use
>> FileZilla client connecting to it and option "Use compression for 
>> all transfers" is on.
>> Exception is thrown in TClientProcessingThread.Execute.
>> Debugger tells me that threads Client.DataStream is nil. However in
>> TFtpServer.DoStartSendData Client.Datastream is assigned, when 
>> passed to the thread. It is strange.
>> 
> I don't see a problem, I use compression all the time since my file
> listings have lost of files, 1,807 in this case. 
>
> Which version of Delphi? Are you using the standard zlib stuff or have
> you changes the defaults? 
>
>   
--
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


[twsocket] FTPServer access violation

2010-03-14 Thread Busai Péter
Hi ICS team!

I'm testing ICS V7 FTP server demo from latest SVN checkout. I use
FileZilla client connecting to it and option "Use compression for all
transfers" is on.
Exception is thrown in TClientProcessingThread.Execute.
Debugger tells me that threads Client.DataStream is nil. However in
TFtpServer.DoStartSendData Client.Datastream is assigned, when passed to
the thread.
It is strange.

Some log:

! 127.0.0.1=ics Completed directory listing for: c:\temp\*.*, Total Files: 3
! 127.0.0.1=ics Using thread to compress upload file: Directory:
c:\temp\*.*, Level 1
! 127.0.0.1=ics Directory 0bytes sent in 0 milliseconds
> 127.0.0.1=ics [6672ms] 226 File sent ok
> 127.0.0.1=ics [6672ms] Failed to compress file - Access violation at
address 0049CE83 in module 'OverbyteIcsFtpServ.exe'. Read of address



Regards
Peter
--
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


[twsocket] THttpSrv slight modification to function ExtractURLEncodedValue

2006-09-12 Thread Busai Péter
Hi!

In one of my html forms I had to use html element " #0 do begin
   Q := P;
   while (P^ <> #0) and (P^ <> '=') do
   Inc(P);
   FoundLen := P - Q; {tps}
   if P^ = '=' then
   Inc(P);
   if (StrLIComp(Q, @Name[1], NameLen) = 0) and
  (NameLen = FoundLen) then begin  {tps}

  {*** Multiple Values ***}
  If Value <> ''
Then Value := Value + #13#10;  // separate values by CrLf
  {**}

   while (P^ <> #0) and (P^ <> '&') do begin
   Ch := P^;
   if Ch = '%' then begin
   Ch := chr(htoi2(P + 1));
   Inc(P, 2);
   end
   else if Ch = '+' then
   Ch := ' ';
   Value := Value + Ch;
   Inc(P);
   end;
   Result := TRUE;
   // break;   {*** Commented *** We are looking for more 
"Name"-s}
end;
while (P^ <> #0) and (P^ <> '&') do
Inc(P);
   if P^ = '&' then
   Inc(P);
   end;
end;

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be