Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2003.09.29;
Скачать: CL | DM;

Вниз

Получаю старую версию файла с сервера! как побороть?   Найти похожие ветки 

 
AlexT1000 ©   (2003-07-22 13:56) [0]

Существует следующий код загрузки файлов с сервера.
Проблема в том , что мне возвращает старые копии скачиваемого файла с сервера если я его там поменяю.
помогает только перезагрузка приложения или очистка кеша виндовс.
КАК СДЕЛАТЬ ТАК ,ЧТО БЫ ВОЗВРАЩАЛАС ЬСАМАЯ СВЕЖАЯ КОПИЯ ВЫКАЧИВАЕМОГО ФАЙЛА?
SetLength(AcceptTypes, 2);
AcceptTypes[0] := PChar("*.*"); AcceptTypes[1] := nil;
Res:=0;
ParseURL(HostName,s, FileName);
Ok:=true;
BytesToRead:=0;
BytesReaded:=0;
if hconnect=nil then
hConnect := InternetConnect(hSession, PChar(s),
INTERNET_DEFAULT_HTTP_PORT, PChar(""), PChar(""), INTERNET_SERVICE_HTTP, 0, 0);
if hconnect=nil then Exit;
if hRequest<>nil then InternetCloseHandle(hRequest);
hRequest := HttpOpenRequest(hConnect,nil ,PChar(FileName),nil,
nil,Pointer(AcceptTypes),
INTERNET_FLAG_EXISTING_CONNECT
,0);
AcceptTypes:=nil;
OK := HttpSendRequest(hRequest, nil, 0, nil, 0);
Res:=GetError(GetLastError);
if Res=1 then begin InternetCloseHandle(hRequest);
InternetCloseHandle(hConnect);
hRequest:=nil;
hConnect:=nil;
end;
if (not Ok) or (hConnect=nil) or (hrequest=nil) then Exit;
if Terminated then Exit; Application.ProcessMessages;
dwIndex := 0;
dwBufLen := 10240;
GetMem(Buf, dwBufLen);
Ok:= HttpQueryInfo(hRequest, HTTP_QUERY_CONTENT_LENGTH,
Buf, dwBufLen, dwIndex);
if Ok then try FileSize := StrToInt(StrPas(Buf));except end
else Exit;
Ok:=true;
FreeMem(Buf);
M:=TMemoryStream.Create;
repeat
FillChar(Data,sizeof (Data),0);
if not InternetReadFile(hRequest, @Data, SizeOf(Data), BytesToRead) then begin Ok:=False;Break; end;
inc(BytesReaded,BytesToRead);
end;
M.Write(Data,BytesToRead);
( hRequest) Существует следующий код загрузки файлов с сервера.
Проблема в том , что мне возвращает старые копии скачиваемого файла с сервера если я его там поменяю.
помогает только перезагрузка приложения или очистка кеша виндовс.
КАК СДЕЛАТЬ ТАК ,ЧТО БЫ ВОЗВРАЩАЛАС ЬСАМАЯ СВЕЖАЯ КОПИЯ ВЫКАЧИВАЕМОГО ФАЙЛА?
SetLength(AcceptTypes, 2);
AcceptTypes[0] := PChar("*.*"); AcceptTypes[1] := nil;
Res:=0;
ParseURL(HostName,s, FileName);
Ok:=true;
BytesToRead:=0;
BytesReaded:=0;
if hconnect=nil then
hConnect := InternetConnect(hSession, PChar(s),
INTERNET_DEFAULT_HTTP_PORT, PChar(""), PChar(""), INTERNET_SERVICE_HTTP, 0, 0);
if hconnect=nil then Exit;
if hRequest<>nil then InternetCloseHandle(hRequest);
hRequest := HttpOpenRequest(hConnect,nil ,PChar(FileName),nil,
nil,Pointer(AcceptTypes),
INTERNET_FLAG_EXISTING_CONNECT
,0);
AcceptTypes:=nil;
OK := HttpSendRequest(hRequest, nil, 0, nil, 0);
Res:=GetError(GetLastError);
if Res=1 then begin InternetCloseHandle(hRequest);
InternetCloseHandle(hConnect);
hRequest:=nil;
hConnect:=nil;
end;
if (not Ok) or (hConnect=nil) or (hrequest=nil) then Exit;
if Terminated then Exit; Application.ProcessMessages;
dwIndex := 0;
dwBufLen := 10240;
GetMem(Buf, dwBufLen);
Ok:= HttpQueryInfo(hRequest, HTTP_QUERY_CONTENT_LENGTH,
Buf, dwBufLen, dwIndex);
if Ok then try FileSize := StrToInt(StrPas(Buf));except end
else Exit;
Ok:=true;
FreeMem(Buf);
M:=TMemoryStream.Create;
repeat
FillChar(Data,sizeof (Data),0);
if not InternetReadFile(hRequest, @Data, SizeOf(Data), BytesToRead) then begin Ok:=False;Break; end;
inc(BytesReaded,BytesToRead);
end;
M.Write(Data,BytesToRead);
until BytesToRead = 0;
InternetCloseHandle(hRequest);hRequest:=nil;

if not Ok then begin M.Free; Exit;end;
M.Position:=0;
end;


 
Е-Моё имя ©   (2003-07-22 16:08) [1]

у hRequest наверна есть свойства-заголовки
добавить надо Pragma: no-cache туда


 
aach_ua ©   (2003-07-29 11:26) [2]

Можно глянуть весь текст исходника?


 
AlexT1000 ©   (2003-07-29 19:57) [3]

а чего тебе еще не хватает?
здесь самая важная часть



Страницы: 1 вся ветка

Текущий архив: 2003.09.29;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.017 c
14-96339
Zoloto
2003-09-11 22:25
2003.09.29
Обрезает форму


3-96113
BorisSV
2003-09-10 14:27
2003.09.29
Про TDBGrid.DataSource


1-96270
Layner
2003-09-17 10:46
2003.09.29
Как готовую bmp влодить в res файл?


1-96253
stone
2003-09-17 15:14
2003.09.29
Заполнить пробелами


14-96423
vidiv
2003-09-10 12:45
2003.09.29
2 Вопроса про PHP