idHTTP problems (Indy 10 and Delphi 7 Ent)

Giganews Newsgroups
Subject: idHTTP problems (Indy 10 and Delphi 7 Ent)
Posted by:  Peter Maddin (petermadd…
Date: Wed, 07 Mar 2007

I am using idHTTP to get and post to a CGIExperts ISAPI DLL on IIS 6.

If I do gets (get a simple web page to show the servers available, get a
list of files to download, then use a get to download a file using the
TStream overloaded method using a file from the previous list), then use
post to upload a file (using IdMultipartFormData for the form variables
and the file to be uploaded), I can no longer use the component to do
additional  gets. I get an exception. I can still do additional posts.

My current work around is to use two instances of idHTTP, one for gets
and one for posts.

Is this correct or is there some method or property I could use to
re-set the component.

Also once I post a file to the server, it remains open and I cannot
delete the local file just uploaded.

From experimenting, if I use post to upload another file, I can then
delete the previous local file.

Is there a way to force idHTTP to close the file.

Also I have a problem with using a get to trigger a file delete on the
IIS server. The server gets two get requests to delete the file. One of
which suceeds and the other fails. I cannot see how this occurs. This
occurs infrequently. Currently around every 500 files uploaded. I have
sucessfully uploaded >900 files without this happening and then it
happens after 200 files on another occasion.

I am considering creating an instance of IdHTTP just prior to each get
or post and freeing that instance after it has completed its task or an
exception has occured. This might well fix the most recently uploaded
file remaining open or getting two delete requests from what appears to
be a single get call. I am not sure if this is good practice or not.

My current logic is

1. Use get to check the server is alive (returns simple web page)
2. Use get to return a list of files to be downloaded (returned as a
simple page)
For each file in the list
    3. Download it using a get with a TStream.
    4. Generate a local acknowledgement file
    5. Post the acknowledgement file to the IIS server
    6. Using the get method, get the isapi dll to delete the file just
downloaded using a get on the server.
    7. Delete the local instance of the acknowledgment file.

It all works well except

Step 6 sometimes results in the get request being handled by two
instances of the isapi dll (logging within this dll writes out the
thread id of the isapi dll instance).

Step 7 A DeleteFile on the local acknowledgement file just posted fails
100% of the time. Previously posted files can be deleted.

I feel as I am 99% of the way there but can't get past the next 1%.
Tomorrow I will try instantiating idHTTP before each get and post to see
if this fixes things but this approach does not feel right.

I was using IP*Work components before and they worked fairly well except
their webupload component did not do everything I wanted. I would have
to revert back to their std HTTP component and set up my own content
using a MIME component. The idHTTP component looked much easier to use.

If you are using a thread to handle http communication, then there is
another problem with version 5 of IP*Works. I have been told that the
next version fixes this but I am not in a position to upgrade right now.