codice:
<%@ Language=VBScript %>
<%
Response.Expires = 0
Response.ExpiresAbsolute = Now() - 1
Response.AddHeader "pragma","no-cache"
Response.AddHeader "cache-control","private"
Response.CacheControl = "no-cache"
Response.Buffer = TRUE
strFileName = request("file")
action = "" & request("act")
sUrl = "http://10.39.144.28/customers/programs/certificati/content/down.asp?file=" & strFileName
HTTPREQUEST_SETCREDENTIALS_FOR_SERVER = 0
HTTPREQUEST_SETCREDENTIALS_FOR_PROXY = 1
iAttempts = 0
bDone = false
Dim objWinHttp
Dim strHTML
Set objWinHttp = Server.CreateObject("WinHttp.WinHttpRequest.5.1")
objWinHttp.Open "GET", sURL, False
Do
iAttempts = iAttempts + 1
objWinHttp.Send
Select Case objWinHttp.Status
Case 200
bDone = True
Case 401
objWinHttp.Open "GET", sURL, False
objWinHttp.SetCredentials "", "", HTTPREQUEST_SETCREDENTIALS_FOR_SERVER
Case 407
objWinHttp.Open "GET", sURL, False
objWinHttp.SetCredentials "", "", HTTPREQUEST_SETCREDENTIALS_FOR_PROXY
End Select
Loop Until bDone Or (iAttempts > 3)
Response.ContentType = objWinHttp.GetResponseHeader("Content-Type")
'response.Write objWinHttp.GetResponseHeader("Content-Type")
'response.end
strHTML = objWinHttp.ResponseBody
'EXTDATO : settaggio HTTP Header documenti
'*************************************************************
arrFile = split(strFileName, ".")
strFileExt = LCase(arrFile(UBound(arrFile)))
select case strFileExt
case "pdf"
strMIME = "application/pdf"
case "doc"
strMIME = "application/msword"
case "xls"
strMIME = "application/vnd.ms-excel"
case "zip"
strMIME = "application/zip"
action = "D"
case "tif"
strMIME = "image/tiff"
case else
strMIME = "application/octet-stream"
end select
'strMIME= "application/octet-stream"
Response.ContentType = strMIME
if action = "D" then 'Download
Response.AddHeader "Content-Disposition", "attachment; filename=""" & strFileName & """"
elseif action = "V" or action = "" then 'View
' Response.AddHeader "Content-Description", """" & arrFile(0) & """"
' Response.AddHeader "Content-Disposition", "inline; filename="&arrFile(0)
end if
'*************************************************************
Response.BinaryWrite(strHTML)
Response.CacheControl = "public"
Set objWinHttp = Nothing
set obj = Nothing
%>
La pagina fa una richiesta HTTP di una pagina che sta su un altro server e recupera il file . Dopodichè setta il content type in modo opportuno.
Che manca ??? :master: