uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- IdTCPClient, IdGlobal, IdException;
+ IdTCPClient, IdCoderMIME, IdGlobal, IdException;
const
SLPP_PORT = 9871;
FSLPPThread: TIdSLPP20ReadThread;
FDebugMode: boolean;
FProxyMode: boolean;
+ FProxyUser: String;
+ FProxyPass: String;
FLUID: String;
FOnSlppEvent: TIdSlppEvent;
FOnConnect: TNotifyEvent;
procedure SetLUID(const Value: String);
procedure SetOnSlppEvent(const Value: TIdSlppEvent);
procedure SetProxyMode(const Value: boolean);
+ procedure SetProxyUser(const Value: String);
+ procedure SetProxyPass(const Value: String);
procedure SetOnConnect(const Value: TNotifyEvent);
procedure SetOnDisconnect(const Value: TNotifyEvent);
function GetLastReadTimeInterval: integer;
property Port default SLPP_PORT;
property DebugMode: boolean read FDebugMode write SetDebugMode;
property ProxyMode: boolean read FProxyMode write SetProxyMode;
+ property ProxyUser: String read FProxyUser write SetProxyUser;
+ property ProxyPass: String read FProxyPass write SetProxyPass;
property OnConnect: TNotifyEvent read FOnConnect write SetOnConnect;
property OnConnectFailed: TNotifyEvent read FOnConnectFailed write SetOnConnectFailed;
property OnDisconnect: TNotifyEvent read FOnDisconnect write SetOnDisconnect;
inherited Create(AOwner);
Port := SLPP_PORT;
Host := SLPP_HOST;
+ ProxyUser := '';
+ ProxyPass := '';
end;
destructor TIdSLPP20.Destroy;
FProxyMode := Value;
end;
+procedure TIdSLPP20.SetProxyUser(const Value: String);
+begin
+ FProxyUser := Value;
+end;
+
+procedure TIdSLPP20.SetProxyPass(const Value: String);
+begin
+ FProxyPass := Value;
+end;
+
{ TIdSLPP20ReadThread }
constructor TIdSLPP20ReadThread.Create(AClient: TIdSLPP20);
procedure TIdSLPP20ReadThread.Execute;
var Line: String;
+ EncodedPassword,PlainPassword: String;
+ Base64Encoder: TIdEncoderMIME;
begin
try
FClient.Connect(FClient.FTimeout);
Exit;
end;
+ EncodedPassword := '';
+ if FClient.ProxyUser <> '' then begin
+ if FClient.ProxyPass <> '' then begin
+ PlainPassword := FClient.ProxyUser + ':' + FClient.ProxyPass;
+ Base64Encoder.Create(nil);
+ EncodedPassword := Base64Encoder.Encode(PlainPassword);
+ FreeAndNil(Base64Encoder);
+ end;
+ end;
+
FRecvData := TStringList.Create;
FReceivedLog := TStringList.Create;
if FClient.ProxyMode then begin
FClient.Writeln('POST http://bottle.mikage.to:9871/ HTTP/1.0');
FClient.Writeln('Content-Length: ' + IntToStr(Length(FClient.LUID)));
FClient.Writeln('Connection: close');
+
+ if EncodedPassword <> '' then begin
+ FClient.Writeln('Proxy-Authorization: Basic ' + EncodedPassword);
+ end;
+
FClient.Writeln;
FClient.Writeln(FClient.LUID);
end else begin
var
command: String;
begin
+ //\8dÅ\92á\8cÀ\83R\83}\83\93\83h\8ds+1\82Í\82È\82¢\82Æ\83_\83\81 - 2\88È\8fã
+ if FRecvData.Count <= 1 then begin
+ Result := false;
+ Exit;
+ end;
+
command := FRecvData[0];
FRecvData.Delete(0);
FParam := FRecvData.Text;