+function TDownloadThread.CgiDownload(ItemType: TGikoDownloadType; URL: string; Modified: TDateTime): Boolean;
+var
+ ResponseCode: Integer;
+ ResStream: TMemoryStream;
+begin
+ ResponseCode := -1;
+ FIndy.Request.ContentRangeStart := 0;
+ FIndy.Request.ContentRangeEnd := 0;
+
+ FIndy.Request.CustomHeaders.Clear;
+ if (Modified <> 0) and (Modified <> ZERO_DATE) then begin
+ FIndy.Request.LastModified := modified - OffsetFromUTC;
+ end;
+ FIndy.Request.AcceptEncoding := '';
+ FIndy.Request.Accept := 'text/html';
+ ResStream := TMemoryStream.Create;
+ try
+ try
+ ResStream.Clear;
+ {$IFDEF DEBUG}
+ Writeln('URL: ' + URL);
+ {$ENDIF}
+ FIndy.Get(URL, ResStream);
+ Item.Content := GikoSys.GzipDecompress(ResStream, FIndy.Response.ContentEncoding);
+ Item.LastModified := FIndy.Response.LastModified;
+ //\8d·\95ª\8eæ\93¾\82Å\82P\83o\83C\83g\91O\82©\82ç\82Æ\82Á\82Ä\82«\82½\82Æ\82«\82Í\83}\83C\83i\83X\82·\82é
+ Item.ContentLength := Length(Item.Content);
+ //\96³\82¢\82Æ\8ev\82¤\82¯\82Ç\81B\81B\81B
+ if Item.Content = '' then
+ Result := False
+ else
+ Result := True;
+ {$IFDEF DEBUG}
+ Writeln('\8eæ\93¾\82Å\97á\8aO\82È\82µ');
+ {$ENDIF}
+ ResponseCode := FIndy.ResponseCode;
+ except
+ on E: EIdSocketError do begin
+ Item.Content := '';
+ Item.LastModified := ZERO_DATE;
+ Item.ContentLength := 0;
+ Item.ErrText := E.Message;
+ Result := False;
+ ResponseCode := -1;
+ Screen.Cursor := crDefault;
+ end;
+ on E: EIdConnectException do begin
+ Item.Content := '';
+ Item.LastModified := ZERO_DATE;
+ Item.ContentLength := 0;
+ Item.ErrText := E.Message;
+ Result := False;
+ ResponseCode := -1;
+ Screen.Cursor := crDefault;
+ end;
+ on E: Exception do begin
+ {$IFDEF DEBUG}
+ Writeln('\8eæ\93¾\82Å\97á\8aO\82 \82è');
+ Writeln('E.Message: ' + E.Message);
+ {$ENDIF}
+ Item.Content := '';
+ Item.LastModified := ZERO_DATE;
+ Item.ContentLength := 0;
+ Item.ErrText := E.Message;
+ ResponseCode := FIndy.ResponseCode;
+ Result := False;
+ Screen.Cursor := crDefault;
+ end;
+ end;
+ finally
+ if (Item.ContentLength = 0) and (ResponseCode = 206) then
+ Item.ResponseCode := 304
+ else
+ Item.ResponseCode := ResponseCode;
+ ResStream.Free;
+ end;
+end;
+