- From: joe bester <bester@mcs.anl.gov>
- Date: Thu, 27 Jan 2000 12:02:28 -0600
- To: www-lib@w3.org
Hi again, I ran into problems running with libwww and wu-2.6.0(3) ftp server. From what I could tell, the ftp server was expecting the client to close the data socket before the server would send the "226 Transfer complete." message. This was causing the FTP state machine to stop. I added a call to HTDoClose to HTFTP.c in the NEED_BODY state when the transfer is completed. I also added some code to allow incremental streaming ftp data into the user application via a PostCallback function. The majority of the patch is actually this handling. I was a little unclear on what the return codes from the post callback are supposed to mean, so it may not be entirely correct... (This patch is against the current CVS) joe Index: HTFTP.c =================================================================== RCS file: /sources/public/libwww/Library/src/HTFTP.c,v retrieving revision 1.106 diff -u -r1.106 HTFTP.c --- HTFTP.c 1999/08/02 22:59:46 1.106 +++ HTFTP.c 2000/01/27 17:34:40 @@ -1069,6 +1069,7 @@ char *segment = NULL; HTNet *dnet = ctrl->dnet; BOOL data_is_active = (sockfd == HTNet_socket(dnet)); + HTPostCallback * pcbf; typedef enum _state { SUB_ERROR = -2, SUB_SUCCESS = -1, @@ -1245,12 +1246,29 @@ int length = (int)HTAnchor_length(entity); HTStream * output = (HTStream *)HTChannel_output(HTNet_host(dnet)->channel); - status = (*output->isa->put_block)(output,document,length); + pcbf = HTRequest_postCallback(request); + if(pcbf) + { + status = (*pcbf)(request, output); + } + else + { + status = (*output->isa->put_block)( + output, + document, + length); + if(status == HT_OK) + { + status = HT_LOADED; + } + } if (status == HT_WOULD_BLOCK) { return HT_WOULD_BLOCK; - } else if ( status == HT_OK ) { + } else if ( status == HT_LOADED ) { ctrl->substate = SUB_SUCCESS; data->complete |= 3; + } else if(status == HT_OK) { + return HT_WOULD_BLOCK; } else { ctrl->substate = SUB_ERROR; data->stream_error = YES; @@ -1262,6 +1280,7 @@ if (status == HT_WOULD_BLOCK) return HT_WOULD_BLOCK; else if (status == HT_LOADED || status == HT_CLOSED || status == HT_OK) { + HTDoClose(dnet); data->complete |= 1; if (data->complete >= 3) ctrl->substate = SUB_SUCCESS;
Received on Thursday, 27 January 2000 13:02:23 UTC