|
@@ -144,7 +144,9 @@ type
|
|
FIsTempProjectLoaded: Boolean;
|
|
FIsTempProjectLoaded: Boolean;
|
|
FTempProjectFile: string;
|
|
FTempProjectFile: string;
|
|
FActiveEditor: TBCEditor;
|
|
FActiveEditor: TBCEditor;
|
|
|
|
+ FRoamingSavePath: string;
|
|
function GetTempProjectFile: string;
|
|
function GetTempProjectFile: string;
|
|
|
|
+ function GetAppVersion: string;
|
|
procedure UpdateFullURL;
|
|
procedure UpdateFullURL;
|
|
procedure LoadProject;
|
|
procedure LoadProject;
|
|
procedure SaveProject;
|
|
procedure SaveProject;
|
|
@@ -165,7 +167,7 @@ implementation
|
|
|
|
|
|
{$R *.dfm}
|
|
{$R *.dfm}
|
|
|
|
|
|
-uses System.NetEncoding, System.UITypes, _EncryptStr, JsonDataObjects, Clipbrd, IdGlobal;
|
|
|
|
|
|
+uses System.NetEncoding, System.UITypes, _EncryptStr, JsonDataObjects, Clipbrd, IdGlobal, System.IOUtils;
|
|
|
|
|
|
procedure TfrmMain.tbbtnRunClick(Sender: TObject);
|
|
procedure TfrmMain.tbbtnRunClick(Sender: TObject);
|
|
begin
|
|
begin
|
|
@@ -420,7 +422,7 @@ end;
|
|
|
|
|
|
procedure TfrmMain.dxBarButton7Click(Sender: TObject);
|
|
procedure TfrmMain.dxBarButton7Click(Sender: TObject);
|
|
begin
|
|
begin
|
|
- MessageDlg('Simnet REST Debugger', mtInformation, [mbOK], 0);
|
|
|
|
|
|
+ MessageDlg('Simnet REST Debugger' + #13#10 + GetAppVersion, mtInformation, [mbOK], 0);
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TfrmMain.dxBarSubItem3Popup(Sender: TObject);
|
|
procedure TfrmMain.dxBarSubItem3Popup(Sender: TObject);
|
|
@@ -528,7 +530,10 @@ end;
|
|
|
|
|
|
procedure TfrmMain.FormCreate(Sender: TObject);
|
|
procedure TfrmMain.FormCreate(Sender: TObject);
|
|
begin
|
|
begin
|
|
- FMainConfig := TJSONConfig.Create(ExtractFilePath(ParamStr(0)) + 'AppConfig.json');
|
|
|
|
|
|
+ FRoamingSavePath := IncludeTrailingPathDelimiter(TPath.GetHomePath) + 'Simnet\RESTDebugger\';
|
|
|
|
+ ForceDirectories(FRoamingSavePath);
|
|
|
|
+
|
|
|
|
+ FMainConfig := TJSONConfig.Create(FRoamingSavePath + 'AppConfig.json');
|
|
FActiveProject := '';
|
|
FActiveProject := '';
|
|
FActivePreset := '';
|
|
FActivePreset := '';
|
|
|
|
|
|
@@ -549,23 +554,34 @@ begin
|
|
|
|
|
|
FActiveEditor := nil;
|
|
FActiveEditor := nil;
|
|
|
|
|
|
|
|
+ HTTP.Request.UserAgent := 'Simnet REST Debugger/' + GetAppVersion;
|
|
|
|
|
|
- if ParamStr(1) <> '' then
|
|
|
|
|
|
+ if (not FMainConfig.ReadBool('Main', 'FirstStartShown')) and (FileExists(IncludeTrailingPathDelimiter(ExtractFilePath(ParamStr(0))) + 'Example Config.rdproj')) then
|
|
begin
|
|
begin
|
|
- FActiveProject := ParamStr(1);
|
|
|
|
|
|
+ FActiveProject := IncludeTrailingPathDelimiter(ExtractFilePath(ParamStr(0))) + 'Example Config.rdproj';
|
|
FIsTempProjectLoaded := False;
|
|
FIsTempProjectLoaded := False;
|
|
|
|
+ FMainConfig.WriteBool('Main', 'FirstStartShown', True);
|
|
|
|
+ FMainConfig.WriteString('Project', 'LastUsed', FActiveProject);
|
|
end
|
|
end
|
|
else
|
|
else
|
|
begin
|
|
begin
|
|
- if (FMainConfig.ReadBool('Project', 'AutoOpenLastUsed')) and (FileExists(FMainConfig.ReadString('Project', 'LastUsed'))) then
|
|
|
|
|
|
+ if ParamStr(1) <> '' then
|
|
begin
|
|
begin
|
|
- FActiveProject := FMainConfig.ReadString('Project', 'LastUsed');
|
|
|
|
|
|
+ FActiveProject := ParamStr(1);
|
|
FIsTempProjectLoaded := False;
|
|
FIsTempProjectLoaded := False;
|
|
end
|
|
end
|
|
else
|
|
else
|
|
begin
|
|
begin
|
|
- FActiveProject := GetTempProjectFile;
|
|
|
|
- FIsTempProjectLoaded := True;
|
|
|
|
|
|
+ if (FMainConfig.ReadBool('Project', 'AutoOpenLastUsed', True)) and (FileExists(FMainConfig.ReadString('Project', 'LastUsed'))) then
|
|
|
|
+ begin
|
|
|
|
+ FActiveProject := FMainConfig.ReadString('Project', 'LastUsed');
|
|
|
|
+ FIsTempProjectLoaded := False;
|
|
|
|
+ end
|
|
|
|
+ else
|
|
|
|
+ begin
|
|
|
|
+ FActiveProject := GetTempProjectFile;
|
|
|
|
+ FIsTempProjectLoaded := True;
|
|
|
|
+ end;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -611,6 +627,34 @@ begin
|
|
dxStatusBar.Panels[1].Text := '';
|
|
dxStatusBar.Panels[1].Text := '';
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+function TfrmMain.GetAppVersion: string;
|
|
|
|
+var
|
|
|
|
+ VerInfoSize: DWORD;
|
|
|
|
+ VerInfo: Pointer;
|
|
|
|
+ VerValueSize: DWORD;
|
|
|
|
+ VerValue: PVSFixedFileInfo;
|
|
|
|
+ dmy: DWORD;
|
|
|
|
+begin
|
|
|
|
+ Result := '';
|
|
|
|
+ VerInfoSize := GetFileVersionInfoSize(PChar(ParamStr(0)), dmy);
|
|
|
|
+ if VerInfoSize = 0 then Exit;
|
|
|
|
+
|
|
|
|
+ GetMem(VerInfo, VerInfoSize);
|
|
|
|
+ try
|
|
|
|
+ GetFileVersionInfo(PChar(ParamStr(0)), 0, VerInfoSize, VerInfo);
|
|
|
|
+ VerQueryValue(VerInfo, '\', Pointer(VerValue), VerValueSize);
|
|
|
|
+ with VerValue^ do
|
|
|
|
+ begin
|
|
|
|
+ Result := IntToStr(dwFileVersionMS shr 16);
|
|
|
|
+ Result := Result + '.' + IntToStr(dwFileVersionMS and $FFFF);
|
|
|
|
+ Result := Result + '.' + IntToStr(dwFileVersionLS shr 16);
|
|
|
|
+ Result := Result + '.' + IntToStr(dwFileVersionLS and $FFFF);
|
|
|
|
+ end;
|
|
|
|
+ finally
|
|
|
|
+ FreeMem(VerInfo, VerInfoSize);
|
|
|
|
+ end;
|
|
|
|
+end;
|
|
|
|
+
|
|
function TfrmMain.GetTempProjectFile: string;
|
|
function TfrmMain.GetTempProjectFile: string;
|
|
var
|
|
var
|
|
iSize: Integer;
|
|
iSize: Integer;
|
|
@@ -779,8 +823,10 @@ begin
|
|
EditorContent.Lines.Clear;
|
|
EditorContent.Lines.Clear;
|
|
EditorResponseHeaders.Lines.Clear;
|
|
EditorResponseHeaders.Lines.Clear;
|
|
|
|
|
|
|
|
+ Screen.Cursor := crHourGlass;
|
|
tick := GetTickCount;
|
|
tick := GetTickCount;
|
|
try
|
|
try
|
|
|
|
+ HTTP.Request.CustomHeaders.Clear;
|
|
HTTP.Request.CustomHeaders.AddStrings(EditorExtraHeaders.Lines);
|
|
HTTP.Request.CustomHeaders.AddStrings(EditorExtraHeaders.Lines);
|
|
|
|
|
|
if chkUseBasicAuth.Checked then
|
|
if chkUseBasicAuth.Checked then
|
|
@@ -788,6 +834,12 @@ begin
|
|
HTTP.Request.Username := edtAuthUsername.Text;
|
|
HTTP.Request.Username := edtAuthUsername.Text;
|
|
HTTP.Request.Password := edtAuthPassword.Text;
|
|
HTTP.Request.Password := edtAuthPassword.Text;
|
|
HTTP.Request.BasicAuthentication := True;
|
|
HTTP.Request.BasicAuthentication := True;
|
|
|
|
+ end
|
|
|
|
+ else
|
|
|
|
+ begin
|
|
|
|
+ HTTP.Request.BasicAuthentication := False;
|
|
|
|
+ HTTP.Request.Username := '';
|
|
|
|
+ HTTP.Request.Password := '';
|
|
end;
|
|
end;
|
|
|
|
|
|
if comboMethod.ItemIndex = 0 then
|
|
if comboMethod.ItemIndex = 0 then
|
|
@@ -795,6 +847,10 @@ begin
|
|
// GET
|
|
// GET
|
|
try
|
|
try
|
|
dmy := HTTP.Get(edtFullURL.Text);
|
|
dmy := HTTP.Get(edtFullURL.Text);
|
|
|
|
+ if HTTP.ResponseCode <> 200 then
|
|
|
|
+ begin
|
|
|
|
+ MessageDlg(HTTP.ResponseText, mtError, [mbOK], 0);
|
|
|
|
+ end;
|
|
except
|
|
except
|
|
on E: Exception do
|
|
on E: Exception do
|
|
begin
|
|
begin
|
|
@@ -811,6 +867,10 @@ begin
|
|
HTTP.Request.ContentType := comboPostContentType.Text;
|
|
HTTP.Request.ContentType := comboPostContentType.Text;
|
|
try
|
|
try
|
|
dmy := HTTP.Post(edtFullURL.Text, strstream);
|
|
dmy := HTTP.Post(edtFullURL.Text, strstream);
|
|
|
|
+ if HTTP.ResponseCode <> 200 then
|
|
|
|
+ begin
|
|
|
|
+ MessageDlg(HTTP.ResponseText, mtError, [mbOK], 0);
|
|
|
|
+ end;
|
|
except
|
|
except
|
|
on E: Exception do
|
|
on E: Exception do
|
|
begin
|
|
begin
|
|
@@ -826,6 +886,7 @@ begin
|
|
EditorResponseHeaders.Lines.Text := HTTP.Response.RawHeaders.Text;
|
|
EditorResponseHeaders.Lines.Text := HTTP.Response.RawHeaders.Text;
|
|
finally
|
|
finally
|
|
dxStatusBar.Panels[1].Text := FormatFloat('Response Time: 0, ms', GetTickCount - tick);
|
|
dxStatusBar.Panels[1].Text := FormatFloat('Response Time: 0, ms', GetTickCount - tick);
|
|
|
|
+ Screen.Cursor := crDefault;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|