PDA

View Full Version : Bug? Http download error not recorded by GetHTTPErrorInfo()


Ken Gartner
03-16-2005, 06:15 AM
The trouble ticket submission page does not allow selection of TU 2.0, so I'll post this here. I am running 2.0.0.0 on Windows XP.

HTTP file download has failed, but the GetHTTPErrorInfo() does not contain correct information in my test scenario.

My code resembles the example code for GetHTTPErrorInfo:

=================
-- Download the latest patch file, locally
local RemotePatchTOCFileURL = _DOWNLOAD_URLBASE.."/PatchTOC.ini";
local LocalPatchTOCFileName = _SourceFolder.."\\PatchTOC.ini";

TrueUpdate.WriteToLogFile("About to download from "..RemotePatchTOCFileURL.." to local "..LocalPatchTOCFileName.."\r\n", true);

HTTP.Download(RemotePatchTOCFileURL, LocalPatchTOCFileName);
if (Application.GetLastError() ~= 0) then
local httpStatus = HTTP.GetHTTPErrorInfo();

TrueUpdate.WriteToLogFile("HTTP Download Error "..httpStatus.Number.." while retrieving Patch TOC\r\n", true);
TrueUpdate.WriteToLogFile(httpStatus.Message.."\r\n", true);
end

================

Since an error was generated, the example shows that GetHTTPErrorInfo() should be called to retrieve the info about it. However, the HTTP download information is 'stale' or incorrect -- at least for me it shows the following in my log file:

================
[03/16/2005 07:10:11] About to download from http://gartner.dysanalytics.com/ecdeupdates/PatchTOC.ini to local C:\temp\ECDE0304B\ECDE_5.0\templates\PatchTOC.ini
[03/16/2005 07:10:11] Error Script: Server Script, [130]: HTTP.Download(RemotePatchTOCFileURL, LocalPatchTOCFileName); (2515)
[03/16/2005 07:10:12] HTTP Download Error 0 while retrieving Patch TOC
[03/16/2005 07:10:12] The operation completed successfully.
=================

This might be a documentation or product error. Can you clarify when GetHTTPErrorInfo() holds the proper error condition information, and when should I rely solely upon the Application.GetLastError() instead?

Thanks.

Ken Gartner

Mark
03-16-2005, 08:56 AM
Hi Ken,

I have made a note about TrueUpdate 2.0 not being available as an option when you try to submit a ticket, so it should be fix as soon as possible.

Now with regards to the problem that you are having, it turns out that this is a bit of a problem with our documentation. If you look in the help file you will see that HTTP.GetHTTPErrorInfo(); returns 3 things in a table:

Number - A WinInet error code
Message - The WinInet error message, associated with that code.
Status - The HTTP Status code returned by the server

In your case what is happening is you are getting a 404 error, file not found, which is a status code returned by the server. So in that case the Number value will be 0 and the Message value will be "The operation completed successfully".

The reason for that is because everything actually worked properly, i.e. getting and Internet connection, connecting to the server and things like that. But when we tried to get the actually file, the Server returned the 404 status, saying that it could not find the file.

If you had an additional line in your if block like this:

TrueUpdate.WriteToLogFile("HTTP status: "..httpStatus.Status.."\r\n", true);

Then you will be logging all of the information returned by HTTP.GetHTTPErrorInfo().

I have also submitted this to be fixed in our documentation.