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.2.1 by yoffy, Mon Apr 19 22:46:48 2004 UTC revision 1.10.2.2 by yoffy, Thu Sep 9 16:20:30 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    
233  begin  begin
234    
235          {$IFDEF DEBUG}          {$IFDEF DEBUG}
236          Writeln('ExternalBoardManager.InternalDownload');          Writeln('ExternalBoardManager.InternalDownload');
237          {$ENDIF}          {$ENDIF}
238          Result := -1;  //      Result := -1;
239    
240          httpSocket := TIdHTTP.Create( nil );          socket := TIdHTTP.Create( nil );
241          try          try
242                  InitializeSocket( httpSocket );                  InitializeSocket( socket );
243    
244                  httpSocket.Request.ContentRangeStart    := inRangeStart;                  socket.Request.ContentRangeStart        := inRangeStart;
245                  httpSocket.Request.ContentRangeEnd              := inRangeEnd;                  socket.Request.ContentRangeEnd          := inRangeEnd;
246                  if (ioModified <> 0) and (ioModified <> ZERO_DATE) then                  if (ioModified <> 0) and (ioModified <> ZERO_DATE) then
247                          httpSocket.Request.LastModified := ioModified - OffsetFromUTC;                          socket.Request.LastModified := ioModified - OffsetFromUTC;
248                  if inRangeStart = 0 then                  if inRangeStart = 0 then
249                          httpSocket.Request.AcceptEncoding := 'gzip'                          socket.Request.AcceptEncoding := 'gzip'
250                  else                  else
251                          httpSocket.Request.AcceptEncoding := '';                          socket.Request.AcceptEncoding := '';
252                  httpSocket.Request.Accept := 'text/html';                  socket.Request.Accept := 'text/html';
253    
254                  resStream := TMemoryStream.Create;                  resStream := TMemoryStream.Create;
255                  try                  try
256                          try                          try
257                                  resStream.Clear;                                  resStream.Clear;
   
258                                  {$IFDEF DEBUG}                                  {$IFDEF DEBUG}
259                                  Writeln('URL: ' + inURL);                                  Writeln('URL: ' + inURL);
260                                  {$ENDIF}                                  {$ENDIF}
261                                  httpSocket.Get( inURL, resStream );                                  socket.Get( inURL, resStream );
262                                  {$IFDEF DEBUG}                                  {$IFDEF DEBUG}
263                                  Writeln('取得で例外なし');                                  Writeln('取得で例外なし');
264                                  {$ENDIF}                                  {$ENDIF}
265    
266                                  content                 := GikoSys.GzipDecompress( resStream, httpSocket.Response.ContentEncoding );                                  content                 := GikoSys.GzipDecompress( resStream, socket.Response.ContentEncoding );
267                                  ioModified      := httpSocket.Response.LastModified;  
268                                    ioModified      := socket.Response.LastModified;
269    
270                                  Result := httpSocket.ResponseCode;                                  Result := socket.ResponseCode;
271                                  if (Length( content ) = 0) and (Result = 206) then                                  if (Length( content ) = 0) and (Result = 206) then
272                                          Result := 304;                                          Result := 304;
273    
# Line 271  begin Line 276  begin
276                                  on E: EIdSocketError do begin                                  on E: EIdSocketError do begin
277                                          ioModified              := ZERO_DATE;                                          ioModified              := ZERO_DATE;
278                                          outResultData   := nil;                                          outResultData   := nil;
279                                            Result                          := socket.ResponseCode;
280                                  end;                                  end;
281                                  on E: EIdConnectException do begin                                  on E: EIdConnectException do begin
282                                          ioModified              := ZERO_DATE;                                          ioModified              := ZERO_DATE;
283                                          outResultData   := nil;                                          outResultData   := nil;
284                                            Result                          := socket.ResponseCode;
285                                          //Item.ErrText  := E.Message;                                          //Item.ErrText  := E.Message;
286                                  end;                                  end;
287                                    //中断されたときココに入る
288                                    on E: EIdClosedSocket do begin
289                                            ioModified              := ZERO_DATE;
290                                            outResultData   := nil;
291                                            Result                          := 408; //既に一部DL成功しているとレスポンスコードが200のままに
292                                                                                                    //なってしまうので、明示的にエラーコードを返す
293                                    end;
294                                  on E: Exception do begin                                  on E: Exception do begin
295                                          {$IFDEF DEBUG}                                          {$IFDEF DEBUG}
296                                          Writeln('取得で例外あり');                                          Writeln('取得で例外あり');
# Line 284  begin Line 298  begin
298                                          {$ENDIF}                                          {$ENDIF}
299                                          ioModified              := ZERO_DATE;                                          ioModified              := ZERO_DATE;
300                                          outResultData   := nil;                                          outResultData   := nil;
301                                          Result                          := httpSocket.ResponseCode;                                          Result                          := socket.ResponseCode;
302                                          //Item.ErrText  := E.Message;                                          //Item.ErrText  := E.Message;
303                                  end;                                  end;
304                          end;                          end;
# Line 293  begin Line 307  begin
307                  end;                  end;
308    
309          finally          finally
310                  httpSocket.Free;                  socket.Free;
311                    socket := nil;
312          end;          end;
313    
314  end;  end;
# Line 311  var Line 326  var
326          content                                         : string;          content                                         : string;
327          resStream                                       : TStringStream;          resStream                                       : TStringStream;
328          sourceStream                    : TStringStream;          sourceStream                    : TStringStream;
329            tmpURL, Protocol, Host, Path, Document, Port, Bookmark : string;
330  begin  begin
331    
332          {$IFDEF DEBUG}          {$IFDEF DEBUG}
# Line 321  begin Line 337  begin
337          httpSocket := TIdHTTP.Create( nil );          httpSocket := TIdHTTP.Create( nil );
338          try          try
339                  InitializeSocket( httpSocket );                  InitializeSocket( httpSocket );
340                    tmpURL := string(inURL);
341                    GikoSys.ParseURI(tmpURL, Protocol,Host, Path, Document, Port, Bookmark);
342                  httpSocket.Request.CustomHeaders.Add('Pragma: no-cache');                  httpSocket.Request.CustomHeaders.Add('Pragma: no-cache');
343                  httpSocket.Request.AcceptLanguage       := 'ja';                  httpSocket.Request.AcceptLanguage       := 'ja';
344                  httpSocket.Request.Accept                                       := 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*';                  httpSocket.Request.Accept                                       := 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*';
345                  httpSocket.Request.ContentType          := 'application/x-www-form-urlencoded';                  httpSocket.Request.ContentType          := 'application/x-www-form-urlencoded';
346                    httpSocket.Request.Referer                      := Protocol + '://' + Host;
347                  resStream                       := TStringStream.Create( content );                  resStream                       := TStringStream.Create( content );
348                  sourceStream    := TStringStream.Create( string( inSource ) );                  sourceStream    := TStringStream.Create( string( inSource ) );
349                  try                  try

Legend:
Removed from v.1.10.2.1  
changed lines
  Added in v.1.10.2.2

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