I’m trying to get images with MSXML2.ServerXMLHTTP, handling the header’s status code to know if the file/image exists or not.
The problem occurs when the image doesn’t exists but the remote server still responds with status code 200. For example, when the remote site redirects from non-existent file to a existent custom 404 error page.
Here my code:
uri = "https://www.fervi.com/ftp/images/P001/20.jpg"
Set xmlHttp = Server.Createobject("MSXML2.ServerXMLHTTP")
xmlHttp.Open "HEAD", uri, true
xmlHttp.Send
If xmlHttp.waitForResponse(5) Then
Select Case xmlHttp.status
Case 200, 202, 302
'*** Code to handle success status
'*** here I need to handle the status = 200 but not get the expected image
Case Else
'*** Code for handling other status
End Select
Else
'*** Code for handling wait too long
End If
EDIT:
I tried with WinHttp.WinHttpRequest.5.1 and WinHttpRequestOption_EnableRedirects set to False but the response status code is still 200, ad you can see in the screenshot:
The file https://www.fervi.com/ftp/images/P001/20.jpg doesn’t exist on the server: it simply redirect to a custom not found page.
6