[twsocket] ICS THttpConnection.AnswerString transfer-encoding chunked
Hi I am using THttpConnection.AnswerString from file OverbyteIcsHttpSrv and want to send several answers in a long running request via transfer-encoding "chunked". What do I have to do for this to be possible? FKeepAliveTimeSec is zero, I set the header of the response before calling answerString. Here my code: response.ContentType:= 'text/json'; response.Param['transfer-encoding']:= 'chunked' ; //does not work with additional the CRLF either. response.Content:= '{ „Progress“: { „Ticket“: „-1“, „Operation“: „StillRunning...“ }}'; response.Content := IntToHex(Length(response.Content),4) + #13#10 + response.Content + #13#10; Request.Answer( response ); Sleep(500); response.Content:= '{"Parameter": "long", "Information": "Sorry that it took so long"}'; response.Content := IntToHex(Length(response.Content),4) + #13#10 + response.Content + #13#10; response.Content := response.Content + '0' + #13#10 + #13#10; Request.Answer( response ); With Request.Answer procedure TAtServerRequestWebICS.Answer( _response: TAtServerResponse ); var flags: THttpGetFlag; begin FConnection.AnswerString( flags , '' {Default Status '200 OK'} , _response.ContentType , _response.Params // 'transfer-encoding: chunked'#$D#$A , _response.Content ); // '003E'#$D#$A'{ „Progress“: { „Ticket“: „-1“, „Operation“: „StillRunning...“ }}'#$D#$A end {Answer}; Debugging the code, I run through both calls to answerString, but only one is sent, it seems. It seems that the FBufHandler in TCustomWSocket.PutDataInSendBuffer is nil. Thank you -- Ralph M. Rickenbach - phone +41 52 536 34 65 - mobile +41 78 697 05 21 - email ra...@rickenba.ch -- 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] ICS FTP Client
Thank you. You have been very helpful. Graham -Original Message- From: twsocket-boun...@elists.org [mailto:twsocket-boun...@elists.org] On Behalf Of Angus Robertson - Magenta Systems Ltd Sent: 16 July 2012 17:38 To: twsocket@elists.org Subject: Re: [twsocket] ICS FTP Client > I had not cleared the "HostFilename" parameter. So the DirAsync still > had this as a parameter. This is deliberate, the FTP command 'LIST directory' is valid, but not totally reliable with all FTP servers, it can save a lot of path commands. 'LIST filename' is also how to check if a specific file exists. The XDMLSD command supported by the ICS web server is the most efficient way of getting all directories in a single command. Angus -- 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 -- 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] ICS FTP Client
> I had not cleared the "HostFilename" parameter. So the DirAsync still > had this as a parameter. This is deliberate, the FTP command 'LIST directory' is valid, but not totally reliable with all FTP servers, it can save a lot of path commands. 'LIST filename' is also how to check if a specific file exists. The XDMLSD command supported by the ICS web server is the most efficient way of getting all directories in a single command. Angus -- 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] ICS FTP Client
I used the demo program from your website in conjunction with Wireshark to monitor what was going on in network land. I then tried my program and the problem was obvious. I knew it would be simple. After doing the GetAsync I had not cleared the "HostFilename" parameter. So the DirAsync still had this as a parameter. Thanks for all your input. Graham -Original Message- From: twsocket-boun...@elists.org [mailto:twsocket-boun...@elists.org] On Behalf Of Angus Robertson - Magenta Systems Ltd Sent: 16 July 2012 15:46 To: twsocket@elists.org Subject: Re: [twsocket] ICS FTP Client > I may well end up using your components, but in the meantime I need to > determine what my problem is here. The component includes an EXE demo, use that against the FTP server and the same root directory specifying get subdirs, and watch the FTP commands and responses the component uses to parse the directories. Or use a decent FTP client like FileZilla that lists commands and responses. If it also fails to list the subdirs, the FTP server is faulty or maybe set so you can only see the root directory. > I know there are files in the sub folder as I can see them with > Windows Explorer. Which does not have any FTP functionality, so is this a local FTP server? Angus -- 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 -- 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] ICS FTP Client
>> I know there are files in the sub folder as I can see them >> with Windows Explorer. > > Which does not have any FTP functionality, so is this a local FTP server? You can browse FTP servers with Windows Explorer, you just need to type the address in the address bar. Ex.: ftp://usern...@ftpserver.com You can even tell it to use passive mode by going in Control Panel->Internet Options->Advanced tab hth -- 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] ICS FTP Client
> I may well end up using your components, but in the meantime I need > to determine what my problem is here. The component includes an EXE demo, use that against the FTP server and the same root directory specifying get subdirs, and watch the FTP commands and responses the component uses to parse the directories. Or use a decent FTP client like FileZilla that lists commands and responses. If it also fails to list the subdirs, the FTP server is faulty or maybe set so you can only see the root directory. > I know there are files in the sub folder as I can see them > with Windows Explorer. Which does not have any FTP functionality, so is this a local FTP server? Angus -- 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] ICS FTP Client
I may well end up using your components, but in the meantime I need to determine what my problem is here. I use DirAsync to get the directory listing. If I set the directory to Test1 and do a DirAsync, I get all the files and folder names. Now If I set the CWD to one of these sub folders and do a DirAsync again, I get a zero length stream returned. I know there are files in the sub folder as I can see them with Windows Explorer. The curious thing is that when I CWD straight to the subfolder after the Connect event, the DirAsync now returns some data in the stream, but only the dot and double dot folders. Any more clues? Graham -Original Message- From: twsocket-boun...@elists.org [mailto:twsocket-boun...@elists.org] On Behalf Of Angus Robertson - Magenta Systems Ltd Sent: 16 July 2012 14:26 To: twsocket@elists.org Subject: Re: [twsocket] ICS FTP Client > Now I change the working directory to Test1/abc. I check with Now I > change the working directory to Test1/abc. PwdAsync that it is correct > and it responds with what I could expect. > Next I try and do a directory listing on this folder. The response > indicates no error, but the stream is of zero size. LIST only returns file in the current directory, so unless there are files in Test1/abc it will return a blank directory. If you want to list all files in sub-directories you have to traverse the directory free listing each directory and combine all the results, or use an FTP that lists all sub-directories in a single command, ie the ICS FTP server. You can try my File Transfer Components which are high level FTP and HTTP components using ICS that will list sub-directories and copy all the files with a single command. http://www.magsys.co.uk/delphi/magxfer.asp Angus -- 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 -- 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] ICS FTP Client
> Now I change the working directory to Test1/abc. I check with > Now I change the working directory to Test1/abc. PwdAsync that > it is correct and it responds with what I could expect. > Next I try and do a directory listing on this folder. The response > indicates no error, but the stream is of zero size. LIST only returns file in the current directory, so unless there are files in Test1/abc it will return a blank directory. If you want to list all files in sub-directories you have to traverse the directory free listing each directory and combine all the results, or use an FTP that lists all sub-directories in a single command, ie the ICS FTP server. You can try my File Transfer Components which are high level FTP and HTTP components using ICS that will list sub-directories and copy all the files with a single command. http://www.magsys.co.uk/delphi/magxfer.asp Angus -- 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] ICS FTP Client
I'm sure this problem is simple to solve but I am tearing my hair out trying to solve it. Imagine I have an FTP site that contains a folder called "Test1". In this folder I have a file called "abc.dat" and another folder just called "abc". So I log on to the FTP site and change the directory (CwdAsync) to Test1. Now I do a directory listing and I get the file abc.dat and the folder abc. So far so good. Now I change the working directory to Test1/abc. I check with PwdAsync that it is correct and it responds with what I could expect. Next I try and do a directory listing on this folder. The response indicates no error, but the stream is of zero size. So something is obviously not right. Next test performed: I login into the FTP site and change directory straight to Test1/abc. Now if I do a directory listing, I get two directories returned, The single and double dot, but still no filenames. Any help much appreciated. Graham -- 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