Reliability of HTTP Get of ASP page

R

ross-mcm

I have an app that gets a file from a web server. An ASP page is
passed
authenitication data (username, password) and a filename. The file is
read
and then output by the ASP page so the only response is the file I am
requesting. The file I want to receive is XML with the major portion
of it
being a Base64-encoded block.

I use the Indy component TidHTTP to get the file:

HTTPClient.Request.ContentType := 'text/html';
HTTPClient.Request.CacheControl := 'no-cache' ;
Response.Text := HTTPClient.Get (TIdURI.URLEncode (URL)) ;

Problem is that more often than not, the returned file contains
errors. In
a 200k file, 2 or 3 characters are often munged. Occasionally I
manage to
receive the file without errors. Small files are OK.

How reliable is the HTTP protocol? Would it be more reliable to
redirect to
the target file from the ASP page. I say this because HTTP seems to
have no
problems getting .ZIP files or huge setup exe files.

TIA,
Ross
 
A

Anthony Jones

ross-mcm said:
I have an app that gets a file from a web server. An ASP page is
passed
authenitication data (username, password) and a filename. The file is
read
and then output by the ASP page so the only response is the file I am
requesting. The file I want to receive is XML with the major portion
of it
being a Base64-encoded block.

I use the Indy component TidHTTP to get the file:

HTTPClient.Request.ContentType := 'text/html';
HTTPClient.Request.CacheControl := 'no-cache' ;
Response.Text := HTTPClient.Get (TIdURI.URLEncode (URL)) ;

Problem is that more often than not, the returned file contains
errors. In
a 200k file, 2 or 3 characters are often munged. Occasionally I
manage to
receive the file without errors. Small files are OK.

How reliable is the HTTP protocol? Would it be more reliable to
redirect to
the target file from the ASP page. I say this because HTTP seems to
have no
problems getting .ZIP files or huge setup exe files.

HTTP is very reliable as you've allready identified. Your problem is
likely to be found because characters encoding is not configured properly.
We really need see the ASP code. Which characters are messup, characters
found in other parts of the XML or in the Base64 part. A common error in
sending XML from ASP is that the XML may be coming down as UTF-8 but the
content-type header does not specify UTF-8.

It would seem more sensible to fetch metadata if there is any as XML then
fetch the file in its raw format. Base64 creates bloat.

Another alternative if your client has the ability to access response
headers and the amount of metadata is small is to simply respond with the
file content and add any metadata need as custom headers to the response.
 
R

ross-mcm

I'm sure the ASP output is arriving OK. The ASP that send the file
is:

var TextStream = LoadFileFSO.OpenTextFile (UserFilePath +
FileIDToLoad, ForReading) ;

while (! TextStream.AtEndOfStream)
{
Line = TextStream.readline () ;
Response.write (Line + "\r\n") ;
}
TextStream.Close () ;

At the suggestion of Gambit, I assigned the reponse to a stream
instead of a stringlist and that cured the problem. I have no idea
why it would make any difference but it has.

Ross McMillan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,814
Latest member
SpicetreeDigital

Latest Threads

Top