Develop and Download Open Source Software

Browse CVS Repository

Diff of /gikonavigoeson/gikonavi/ExternalBoardPlugInMain.pas

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.10 by h677, Sun Apr 4 14:10:26 2004 UTC revision 1.11 by h677, Tue Jun 29 15:31:28 2004 UTC
# Line 60  type Line 60  type
60                  inFileName      : PChar         // スレッドファイル名                  inFileName      : PChar         // スレッドファイル名
61          ) : PChar; stdcall;                     // スレッドの URL          ) : PChar; stdcall;                     // スレッドの URL
62    
63    
64  function CreateResultString(  function CreateResultString(
65          resultStr : string          resultStr : string
66  ) : PChar; stdcall;  ) : PChar; stdcall;
# Line 68  procedure DisposeResultString( Line 69  procedure DisposeResultString(
69          resultStr : PChar          resultStr : PChar
70  ); stdcall;  ); stdcall;
71    
72    var
73            socket : TIdHTTP;
74    
75  implementation  implementation
76    
77  uses ExternalBoardManager, ExternalThreadItem, GikoSystem, BoardGroup, Giko;  uses ExternalBoardManager, ExternalThreadItem, GikoSystem, BoardGroup, Giko;
# Line 222  function InternalDownload( Line 226  function InternalDownload(
226          inRangeEnd                              : DWORD         // 終了位置          inRangeEnd                              : DWORD         // 終了位置
227  ) : Longint; stdcall;                                   // レスポンスコード  ) : Longint; stdcall;                                   // レスポンスコード
228  var  var
229          httpSocket                              : TIdHTTP;  //      httpSocket                              : TIdHTTP;
230          resStream                                       : TMemoryStream;          resStream                                       : TMemoryStream;
231          content                                         : string;          content                                         : string;
232  begin  begin
# Line 230  begin Line 234  begin
234          {$IFDEF DEBUG}          {$IFDEF DEBUG}
235          Writeln('ExternalBoardManager.InternalDownload');          Writeln('ExternalBoardManager.InternalDownload');
236          {$ENDIF}          {$ENDIF}
237          Result := -1;  //      Result := -1;
238    
239          httpSocket := TIdHTTP.Create( nil );          socket := TIdHTTP.Create( nil );
240          try          try
241                  InitializeSocket( httpSocket );                  InitializeSocket( socket );
242    
243                  httpSocket.Request.ContentRangeStart    := inRangeStart;                  socket.Request.ContentRangeStart        := inRangeStart;
244                  httpSocket.Request.ContentRangeEnd              := inRangeEnd;                  socket.Request.ContentRangeEnd          := inRangeEnd;
245                  if (ioModified <> 0) and (ioModified <> ZERO_DATE) then                  if (ioModified <> 0) and (ioModified <> ZERO_DATE) then
246                          httpSocket.Request.LastModified := ioModified - OffsetFromUTC;                          socket.Request.LastModified := ioModified - OffsetFromUTC;
247                  if inRangeStart = 0 then                  if inRangeStart = 0 then
248                          httpSocket.Request.AcceptEncoding := 'gzip'                          socket.Request.AcceptEncoding := 'gzip'
249                  else                  else
250                          httpSocket.Request.AcceptEncoding := '';                          socket.Request.AcceptEncoding := '';
251                  httpSocket.Request.Accept := 'text/html';                  socket.Request.Accept := 'text/html';
252    
253                  resStream := TMemoryStream.Create;                  resStream := TMemoryStream.Create;
254                  try                  try
255                          try                          try
256                                  resStream.Clear;                                  resStream.Clear;
   
257                                  {$IFDEF DEBUG}                                  {$IFDEF DEBUG}
258                                  Writeln('URL: ' + inURL);                                  Writeln('URL: ' + inURL);
259                                  {$ENDIF}                                  {$ENDIF}
260                                  httpSocket.Get( inURL, resStream );                                  socket.Get( inURL, resStream );
261                                  {$IFDEF DEBUG}                                  {$IFDEF DEBUG}
262                                  Writeln('取得で例外なし');                                  Writeln('取得で例外なし');
263                                  {$ENDIF}                                  {$ENDIF}
264    
265                                  content                 := GikoSys.GzipDecompress( resStream, httpSocket.Response.ContentEncoding );                                  content                 := GikoSys.GzipDecompress( resStream, socket.Response.ContentEncoding );
                                 ioModified      := httpSocket.Response.LastModified;  
266    
267                                  Result := httpSocket.ResponseCode;                                  ioModified      := socket.Response.LastModified;
268    
269                                    Result := socket.ResponseCode;
270                                  if (Length( content ) = 0) and (Result = 206) then                                  if (Length( content ) = 0) and (Result = 206) then
271                                          Result := 304;                                          Result := 304;
272    
# Line 271  begin Line 275  begin
275                                  on E: EIdSocketError do begin                                  on E: EIdSocketError do begin
276                                          ioModified              := ZERO_DATE;                                          ioModified              := ZERO_DATE;
277                                          outResultData   := nil;                                          outResultData   := nil;
278                                            Result                          := socket.ResponseCode;
279                                  end;                                  end;
280                                  on E: EIdConnectException do begin                                  on E: EIdConnectException do begin
281                                          ioModified              := ZERO_DATE;                                          ioModified              := ZERO_DATE;
282                                          outResultData   := nil;                                          outResultData   := nil;
283                                            Result                          := socket.ResponseCode;
284                                          //Item.ErrText  := E.Message;                                          //Item.ErrText  := E.Message;
285                                  end;                                  end;
286                                    //中断されたときココに入る
287                                    on E: EIdClosedSocket do begin
288                                            ioModified              := ZERO_DATE;
289                                            outResultData   := nil;
290                                            Result                          := 408; //既に一部DL成功しているとレスポンスコードが200のままに
291                                                                                                    //なってしまうので、明示的にエラーコードを返す
292                                    end;
293                                  on E: Exception do begin                                  on E: Exception do begin
294                                          {$IFDEF DEBUG}                                          {$IFDEF DEBUG}
295                                          Writeln('取得で例外あり');                                          Writeln('取得で例外あり');
# Line 284  begin Line 297  begin
297                                          {$ENDIF}                                          {$ENDIF}
298                                          ioModified              := ZERO_DATE;                                          ioModified              := ZERO_DATE;
299                                          outResultData   := nil;                                          outResultData   := nil;
300                                          Result                          := httpSocket.ResponseCode;                                          Result                          := socket.ResponseCode;
301                                          //Item.ErrText  := E.Message;                                          //Item.ErrText  := E.Message;
302                                  end;                                  end;
303                          end;                          end;
# Line 293  begin Line 306  begin
306                  end;                  end;
307    
308          finally          finally
309                  httpSocket.Free;                  socket.Free;
310                    socket := nil;
311          end;          end;
312    
313  end;  end;

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26