uses
Windows, Classes, SysUtils, Menus,
IdHTTP, IdComponent, IdGlobal, IdException,
- AbonUnit;
+ AbonUnit, IdAntiFreezeBase;
type
): TAcceptType; stdcall; // URL \82Ì\8eí\97Þ
// *************************************************************************
+ // \8ew\92è\82µ\82½URL\82ð\8c»\8dÝ\82ÌURL\82É\95Ï\8a·\82·\82é
+ // *************************************************************************
+ TOnExtractBoardURL = procedure(
+ inURL : PChar; // \95Ï\8a·\82·\82éURL;
+ var outURL: PChar // \95Ï\8a·\82³\82ê\82½URL
+ ); stdcall; // \95Ï\8a·\82³\82ê\82½URL
+
+ // *************************************************************************
// \83\81\83j\83\85\81[\83n\83\93\83h\83\89
// *************************************************************************
TOnPlugInMenu = procedure(
inFileName : PChar // \83X\83\8c\83b\83h\83t\83@\83C\83\8b\96¼
) : PChar; stdcall; // \83X\83\8c\83b\83h\82Ì URL
+
function CreateResultString(
resultStr : string
) : PChar; stdcall;
resultStr : PChar
); stdcall;
+var
+ socket : TIdHTTP;
+
implementation
uses ExternalBoardManager, ExternalThreadItem, GikoSystem, BoardGroup, Giko;
inSocket.Request.UserAgent := GikoSys.GetUserAgent;
inSocket.RecvBufferSize := Gikosys.Setting.RecvBufferSize;
inSocket.ProxyParams.BasicAuthentication := False;
+ inSocket.ReadTimeout := GikoSys.Setting.ReadTimeOut;
{$IFDEF DEBUG}
Writeln('------------------------------------------------------------');
{$ENDIF}
inRangeEnd : DWORD // \8fI\97¹\88Ê\92u
) : Longint; stdcall; // \83\8c\83X\83|\83\93\83X\83R\81[\83h
var
- httpSocket : TIdHTTP;
+// httpSocket : TIdHTTP;
resStream : TMemoryStream;
content : string;
+const
+ LIVEDOOR_URL = 'http://jbbs.livedoor.jp/';
begin
+
{$IFDEF DEBUG}
Writeln('ExternalBoardManager.InternalDownload');
{$ENDIF}
- Result := -1;
+// Result := -1;
- httpSocket := TIdHTTP.Create( nil );
+ socket := TIdHTTP.Create( nil );
try
- InitializeSocket( httpSocket );
-
- httpSocket.Request.ContentRangeStart := inRangeStart;
- httpSocket.Request.ContentRangeEnd := inRangeEnd;
+ InitializeSocket( socket );
+ socket.Request.ContentRangeStart := inRangeStart;
+ socket.Request.ContentRangeEnd := inRangeEnd;
if (ioModified <> 0) and (ioModified <> ZERO_DATE) then
- httpSocket.Request.LastModified := ioModified - OffsetFromUTC;
+ socket.Request.LastModified := ioModified - OffsetFromUTC;
if inRangeStart = 0 then
- httpSocket.Request.AcceptEncoding := 'gzip'
+ socket.Request.AcceptEncoding := 'gzip'
else
- httpSocket.Request.AcceptEncoding := '';
- httpSocket.Request.Accept := 'text/html';
+ socket.Request.AcceptEncoding := '';
+ socket.Request.Accept := 'text/html';
resStream := TMemoryStream.Create;
try
try
resStream.Clear;
-
{$IFDEF DEBUG}
Writeln('URL: ' + inURL);
{$ENDIF}
- httpSocket.Get( inURL, resStream );
+ //AntiFreeze\82ðDL\8e\9e\82Ì\82Ý\97L\8cø\82É\82·\82é\82±\82Æ\82Å\81A\83R\83R\82Å\82Ì\83`\83F\83b\83N\95s\97v
+ socket.Get( inURL, resStream );
{$IFDEF DEBUG}
Writeln('\8eæ\93¾\82Å\97á\8aO\82È\82µ');
{$ENDIF}
- content := GikoSys.GzipDecompress( resStream, httpSocket.Response.ContentEncoding );
- ioModified := httpSocket.Response.LastModified;
+ content := GikoSys.GzipDecompress( resStream, socket.Response.ContentEncoding );
- Result := httpSocket.ResponseCode;
+ ioModified := socket.Response.LastModified;
+
+ Result := socket.ResponseCode;
if (Length( content ) = 0) and (Result = 206) then
Result := 304;
-
+ //\82µ\82½\82ç\82ÎJBBS\82Í\83w\83b\83_\82É\83G\83\89\81[\8fî\95ñ\82ª\8dÚ\82é\82ç\82µ\82¢\82Ì\82Å\81A\82±\82±\82Å\83`\83F\83b\83N
+ if ( AnsiPos(LIVEDOOR_URL, inURL) > 0 ) and (Result = 200) then begin
+ if( AnsiPos('STORAGE IN', socket.Response.RawHeaders.Text) > 0 ) then begin
+ Result := 302;
+ end;
+ end;
outResultData := CreateResultString( content );
except
on E: EIdSocketError do begin
ioModified := ZERO_DATE;
outResultData := nil;
+ Result := socket.ResponseCode;
end;
on E: EIdConnectException do begin
ioModified := ZERO_DATE;
outResultData := nil;
+ Result := socket.ResponseCode;
//Item.ErrText := E.Message;
end;
+ //\92\86\92f\82³\82ê\82½\82Æ\82«\83R\83R\82É\93ü\82é
+ on E: EIdClosedSocket do begin
+ ioModified := ZERO_DATE;
+ outResultData := nil;
+ Result := 408; //\8aù\82É\88ê\95\94DL\90¬\8c÷\82µ\82Ä\82¢\82é\82Æ\83\8c\83X\83|\83\93\83X\83R\81[\83h\82ª200\82Ì\82Ü\82Ü\82É
+ //\82È\82Á\82Ä\82µ\82Ü\82¤\82Ì\82Å\81A\96¾\8e¦\93I\82É\83G\83\89\81[\83R\81[\83h\82ð\95Ô\82·
+ end;
on E: Exception do begin
{$IFDEF DEBUG}
Writeln('\8eæ\93¾\82Å\97á\8aO\82 \82è');
{$ENDIF}
ioModified := ZERO_DATE;
outResultData := nil;
- Result := httpSocket.ResponseCode;
+ Result := socket.ResponseCode;
//Item.ErrText := E.Message;
end;
end;
end;
finally
- httpSocket.Free;
+ socket.Free;
+ socket := nil;
end;
end;
function InternalPost(
inURL : PChar; // \91\97\90M\82·\82é URL
inSource : PChar; // \91\97\90M\82·\82é\93à\97e
+ inReferer : PChar; // Referer
var outResultData : PChar // \95Ô\82Á\82Ä\82«\82½\95¶\8e\9a\97ñ
) : Longint; stdcall; // \83\8c\83X\83|\83\93\83X\83R\81[\83h
var
content : string;
resStream : TStringStream;
sourceStream : TStringStream;
+
begin
{$IFDEF DEBUG}
httpSocket := TIdHTTP.Create( nil );
try
InitializeSocket( httpSocket );
-
httpSocket.Request.CustomHeaders.Add('Pragma: no-cache');
httpSocket.Request.AcceptLanguage := 'ja';
httpSocket.Request.Accept := 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*';
httpSocket.Request.ContentType := 'application/x-www-form-urlencoded';
-
+ httpSocket.Request.Referer := string(inReferer);
resStream := TStringStream.Create( content );
sourceStream := TStringStream.Create( string( inSource ) );
try
// \83_\83~\81[\82Ì\83N\83\89\83X
board := TBoard.Create( nil, 'about://dummy/' );
- threadItem := TThreadItem.Create( nil, 'about://dummy/test/read.cgi/dummy/' );
+ threadItem := TThreadItem.Create( nil, board, 'about://dummy/test/read.cgi/dummy/' );
try
try
board.Add( threadItem );