|
@@ -28,7 +28,6 @@ type
|
|
dxSkinController: TdxSkinController;
|
|
dxSkinController: TdxSkinController;
|
|
Label1: TLabel;
|
|
Label1: TLabel;
|
|
Image: TImage;
|
|
Image: TImage;
|
|
- HTTP: TIdHTTP;
|
|
|
|
SSLIOHandlerSocketOpenSSL: TIdSSLIOHandlerSocketOpenSSL;
|
|
SSLIOHandlerSocketOpenSSL: TIdSSLIOHandlerSocketOpenSSL;
|
|
dxStatusBar: TdxStatusBar;
|
|
dxStatusBar: TdxStatusBar;
|
|
dxBarManager: TdxBarManager;
|
|
dxBarManager: TdxBarManager;
|
|
@@ -179,6 +178,7 @@ type
|
|
FTempProjectFile: string;
|
|
FTempProjectFile: string;
|
|
FRoamingSavePath: string;
|
|
FRoamingSavePath: string;
|
|
FSearchFromCaret: Boolean;
|
|
FSearchFromCaret: Boolean;
|
|
|
|
+ FHTTP: TIdHTTP;
|
|
function GetTempProjectFile: string;
|
|
function GetTempProjectFile: string;
|
|
function GetAppVersion: string;
|
|
function GetAppVersion: string;
|
|
procedure UpdateFullURL;
|
|
procedure UpdateFullURL;
|
|
@@ -456,7 +456,7 @@ begin
|
|
UpdateFile.Add('timeout 1');
|
|
UpdateFile.Add('timeout 1');
|
|
UpdateFile.Add('taskkill /F /IM RESTDebugger.exe');
|
|
UpdateFile.Add('taskkill /F /IM RESTDebugger.exe');
|
|
UpdateFile.Add('"%~dp0Update.exe" -o"' + ExtractFilePath(ParamStr(0)) + '" -y');
|
|
UpdateFile.Add('"%~dp0Update.exe" -o"' + ExtractFilePath(ParamStr(0)) + '" -y');
|
|
- UpdateFile.Add('start "" "' + ParamStr(0) + '" "/updated"');
|
|
|
|
|
|
+ UpdateFile.Add('start "" "' + ParamStr(0) + '"');
|
|
UpdateFile.Add('del "%~dp0Update.exe"');
|
|
UpdateFile.Add('del "%~dp0Update.exe"');
|
|
UpdateFile.Add('del "%~dp0Update.cmd"');
|
|
UpdateFile.Add('del "%~dp0Update.cmd"');
|
|
UpdateFile.SaveToFile(IncludeTrailingPathDelimiter(TPath.GetTempPath) + 'Update.cmd');
|
|
UpdateFile.SaveToFile(IncludeTrailingPathDelimiter(TPath.GetTempPath) + 'Update.cmd');
|
|
@@ -627,13 +627,13 @@ var
|
|
begin
|
|
begin
|
|
try
|
|
try
|
|
case AMethodType of
|
|
case AMethodType of
|
|
- mtGET: dmy := HTTP.Get(edtFullURL.Text);
|
|
|
|
- mtDELETE: dmy := HTTP.Delete(edtFullURL.Text);
|
|
|
|
|
|
+ mtGET: dmy := FHTTP.Get(edtFullURL.Text);
|
|
|
|
+ mtDELETE: dmy := FHTTP.Delete(edtFullURL.Text);
|
|
end;
|
|
end;
|
|
|
|
|
|
- if HTTP.ResponseCode.ToString[1] <> '2' then
|
|
|
|
|
|
+ if FHTTP.ResponseCode.ToString[1] <> '2' then
|
|
begin
|
|
begin
|
|
- ShowError(HTTP.ResponseText);
|
|
|
|
|
|
+ ShowError(FHTTP.ResponseText);
|
|
end;
|
|
end;
|
|
except
|
|
except
|
|
on E: Exception do
|
|
on E: Exception do
|
|
@@ -645,7 +645,7 @@ begin
|
|
ActiveEditor := EditorContent;
|
|
ActiveEditor := EditorContent;
|
|
UpdateEditor(dmy);
|
|
UpdateEditor(dmy);
|
|
ActiveEditor := EditorResponseHeaders;
|
|
ActiveEditor := EditorResponseHeaders;
|
|
- UpdateEditor(HTTP.Response.RawHeaders.Text);
|
|
|
|
|
|
+ UpdateEditor(FHTTP.Response.RawHeaders.Text);
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TfrmMain.DoPOSTRequest(const AMethodType: TMethodType);
|
|
procedure TfrmMain.DoPOSTRequest(const AMethodType: TMethodType);
|
|
@@ -655,17 +655,17 @@ var
|
|
begin
|
|
begin
|
|
strstream := TStringStream.Create(EditorPostData.Lines.Text, TEncoding.UTF8);
|
|
strstream := TStringStream.Create(EditorPostData.Lines.Text, TEncoding.UTF8);
|
|
try
|
|
try
|
|
- HTTP.Request.ContentType := comboPostContentType.Text;
|
|
|
|
|
|
+ FHTTP.Request.ContentType := comboPostContentType.Text;
|
|
try
|
|
try
|
|
case AMethodType of
|
|
case AMethodType of
|
|
- mtPOST: dmy := HTTP.Post(edtFullURL.Text, strstream);
|
|
|
|
- mtPATCH: dmy := HTTP.Patch(edtFullURL.Text, strstream);
|
|
|
|
- mtPUT: dmy := HTTP.Put(edtFullURL.Text, strstream);
|
|
|
|
|
|
+ mtPOST: dmy := FHTTP.Post(edtFullURL.Text, strstream);
|
|
|
|
+ mtPATCH: dmy := FHTTP.Patch(edtFullURL.Text, strstream);
|
|
|
|
+ mtPUT: dmy := FHTTP.Put(edtFullURL.Text, strstream);
|
|
end;
|
|
end;
|
|
|
|
|
|
- if HTTP.ResponseCode.ToString[1] <> '2' then
|
|
|
|
|
|
+ if FHTTP.ResponseCode.ToString[1] <> '2' then
|
|
begin
|
|
begin
|
|
- ShowError(HTTP.ResponseText);
|
|
|
|
|
|
+ ShowError(FHTTP.ResponseText);
|
|
end;
|
|
end;
|
|
except
|
|
except
|
|
on E: Exception do
|
|
on E: Exception do
|
|
@@ -680,7 +680,7 @@ begin
|
|
ActiveEditor := EditorContent;
|
|
ActiveEditor := EditorContent;
|
|
UpdateEditor(dmy);
|
|
UpdateEditor(dmy);
|
|
ActiveEditor := EditorResponseHeaders;
|
|
ActiveEditor := EditorResponseHeaders;
|
|
- UpdateEditor(HTTP.Response.RawHeaders.Text);
|
|
|
|
|
|
+ UpdateEditor(FHTTP.Response.RawHeaders.Text);
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TfrmMain.DoSearchReplaceText(AReplace, ABackwards: Boolean);
|
|
procedure TfrmMain.DoSearchReplaceText(AReplace, ABackwards: Boolean);
|
|
@@ -941,8 +941,6 @@ begin
|
|
|
|
|
|
ActiveEditor := nil;
|
|
ActiveEditor := nil;
|
|
|
|
|
|
- HTTP.Request.UserAgent := 'Simnet REST Debugger/' + GetAppVersion;
|
|
|
|
-
|
|
|
|
if (not MainConfig.ReadBool('Main', 'FirstStartShown')) and (FileExists(IncludeTrailingPathDelimiter(ExtractFilePath(ParamStr(0))) + 'Example Config.rdproj')) then
|
|
if (not MainConfig.ReadBool('Main', 'FirstStartShown')) and (FileExists(IncludeTrailingPathDelimiter(ExtractFilePath(ParamStr(0))) + 'Example Config.rdproj')) then
|
|
begin
|
|
begin
|
|
FActiveProject := IncludeTrailingPathDelimiter(ExtractFilePath(ParamStr(0))) + 'Example Config.rdproj';
|
|
FActiveProject := IncludeTrailingPathDelimiter(ExtractFilePath(ParamStr(0))) + 'Example Config.rdproj';
|
|
@@ -952,7 +950,7 @@ begin
|
|
end
|
|
end
|
|
else
|
|
else
|
|
begin
|
|
begin
|
|
- if (ParamStr(1) <> '') and not (LowerCase(ParamStr(1)) = '/updated') then
|
|
|
|
|
|
+ if (ParamStr(1) <> '') then
|
|
begin
|
|
begin
|
|
FActiveProject := ParamStr(1);
|
|
FActiveProject := ParamStr(1);
|
|
FIsTempProjectLoaded := False;
|
|
FIsTempProjectLoaded := False;
|
|
@@ -1049,11 +1047,6 @@ begin
|
|
|
|
|
|
|
|
|
|
CheckForUpdate;
|
|
CheckForUpdate;
|
|
-
|
|
|
|
- if LowerCase(ParamStr(1)) = '/updated' then
|
|
|
|
- begin
|
|
|
|
- //ShowMessage('updated');
|
|
|
|
- end;
|
|
|
|
end;
|
|
end;
|
|
|
|
|
|
function TfrmMain.GetAppVersion: string;
|
|
function TfrmMain.GetAppVersion: string;
|
|
@@ -1288,84 +1281,94 @@ procedure TfrmMain.Run;
|
|
var
|
|
var
|
|
tick: Cardinal;
|
|
tick: Cardinal;
|
|
begin
|
|
begin
|
|
- EditorContent.Lines.Clear;
|
|
|
|
- EditorResponseHeaders.Lines.Clear;
|
|
|
|
-
|
|
|
|
- Screen.Cursor := crHourGlass;
|
|
|
|
- tick := GetTickCount;
|
|
|
|
|
|
+ FHTTP := TIdHTTP.Create(nil);
|
|
|
|
+ FHTTP.IOHandler := SSLIOHandlerSocketOpenSSL;
|
|
|
|
+ FHTTP.HTTPOptions := [];
|
|
|
|
+ FHTTP.HandleRedirects := True;
|
|
|
|
+ FHTTP.AllowCookies := True;
|
|
|
|
+ FHTTP.Request.UserAgent := 'Simnet REST Debugger/' + GetAppVersion;
|
|
try
|
|
try
|
|
- HTTP.Request.CustomHeaders.Clear;
|
|
|
|
- HTTP.Request.CustomHeaders.AddStrings(EditorExtraHeaders.Lines);
|
|
|
|
|
|
+ EditorContent.Lines.Clear;
|
|
|
|
+ EditorResponseHeaders.Lines.Clear;
|
|
|
|
|
|
- if chkUseBasicAuth.Checked then
|
|
|
|
- begin
|
|
|
|
- HTTP.Request.Username := edtAuthUsername.Text;
|
|
|
|
- HTTP.Request.Password := edtAuthPassword.Text;
|
|
|
|
- HTTP.Request.BasicAuthentication := True;
|
|
|
|
- end
|
|
|
|
- else
|
|
|
|
- begin
|
|
|
|
- HTTP.Request.BasicAuthentication := False;
|
|
|
|
- HTTP.Request.Username := '';
|
|
|
|
- HTTP.Request.Password := '';
|
|
|
|
- end;
|
|
|
|
|
|
+ Screen.Cursor := crHourGlass;
|
|
|
|
+ tick := GetTickCount;
|
|
|
|
+ try
|
|
|
|
+ FHTTP.Request.CustomHeaders.Clear;
|
|
|
|
+ FHTTP.Request.CustomHeaders.AddStrings(EditorExtraHeaders.Lines);
|
|
|
|
|
|
- if comboMethod.ItemIndex = 0 then
|
|
|
|
- begin
|
|
|
|
- // GET
|
|
|
|
- DoGETRequest(mtGET);
|
|
|
|
- end
|
|
|
|
- else
|
|
|
|
- if comboMethod.ItemIndex = 1 then
|
|
|
|
- begin
|
|
|
|
- // POST
|
|
|
|
- DoPOSTRequest(mtPOST);
|
|
|
|
- end
|
|
|
|
- else
|
|
|
|
- if comboMethod.ItemIndex = 2 then
|
|
|
|
- begin
|
|
|
|
- // PATCH
|
|
|
|
- DoPOSTRequest(mtPATCH);
|
|
|
|
- end
|
|
|
|
- else
|
|
|
|
- if comboMethod.ItemIndex = 3 then
|
|
|
|
- begin
|
|
|
|
- // PUT
|
|
|
|
- DoPOSTRequest(mtPUT);
|
|
|
|
- end
|
|
|
|
- else
|
|
|
|
- if comboMethod.ItemIndex = 4 then
|
|
|
|
- begin
|
|
|
|
- // DELETE
|
|
|
|
- DoGETRequest(mtDELETE);
|
|
|
|
- end;
|
|
|
|
- finally
|
|
|
|
|
|
+ if chkUseBasicAuth.Checked then
|
|
|
|
+ begin
|
|
|
|
+ FHTTP.Request.Username := edtAuthUsername.Text;
|
|
|
|
+ FHTTP.Request.Password := edtAuthPassword.Text;
|
|
|
|
+ FHTTP.Request.BasicAuthentication := True;
|
|
|
|
+ end
|
|
|
|
+ else
|
|
|
|
+ begin
|
|
|
|
+ FHTTP.Request.BasicAuthentication := False;
|
|
|
|
+ FHTTP.Request.Username := '';
|
|
|
|
+ FHTTP.Request.Password := '';
|
|
|
|
+ end;
|
|
|
|
|
|
- if Pos('application/json', HTTP.Response.ContentType) > 0 then
|
|
|
|
- begin
|
|
|
|
- EditorContent.Highlighter := SynJSONSyn;
|
|
|
|
- end
|
|
|
|
- else
|
|
|
|
- if Pos('text/xml', HTTP.Response.ContentType) > 0 then
|
|
|
|
- begin
|
|
|
|
- EditorContent.Highlighter := SynXMLSyn;
|
|
|
|
- end
|
|
|
|
- else
|
|
|
|
- if Pos('text/html', HTTP.Response.ContentType) > 0 then
|
|
|
|
- begin
|
|
|
|
- EditorContent.Highlighter := SynHTMLSyn;
|
|
|
|
- end
|
|
|
|
- else
|
|
|
|
- begin
|
|
|
|
- EditorContent.Highlighter := nil;
|
|
|
|
- end;
|
|
|
|
|
|
+ if comboMethod.ItemIndex = 0 then
|
|
|
|
+ begin
|
|
|
|
+ // GET
|
|
|
|
+ DoGETRequest(mtGET);
|
|
|
|
+ end
|
|
|
|
+ else
|
|
|
|
+ if comboMethod.ItemIndex = 1 then
|
|
|
|
+ begin
|
|
|
|
+ // POST
|
|
|
|
+ DoPOSTRequest(mtPOST);
|
|
|
|
+ end
|
|
|
|
+ else
|
|
|
|
+ if comboMethod.ItemIndex = 2 then
|
|
|
|
+ begin
|
|
|
|
+ // PATCH
|
|
|
|
+ DoPOSTRequest(mtPATCH);
|
|
|
|
+ end
|
|
|
|
+ else
|
|
|
|
+ if comboMethod.ItemIndex = 3 then
|
|
|
|
+ begin
|
|
|
|
+ // PUT
|
|
|
|
+ DoPOSTRequest(mtPUT);
|
|
|
|
+ end
|
|
|
|
+ else
|
|
|
|
+ if comboMethod.ItemIndex = 4 then
|
|
|
|
+ begin
|
|
|
|
+ // DELETE
|
|
|
|
+ DoGETRequest(mtDELETE);
|
|
|
|
+ end;
|
|
|
|
+ finally
|
|
|
|
|
|
- EditorContent.SetFocus;
|
|
|
|
|
|
+ if Pos('application/json', FHTTP.Response.ContentType) > 0 then
|
|
|
|
+ begin
|
|
|
|
+ EditorContent.Highlighter := SynJSONSyn;
|
|
|
|
+ end
|
|
|
|
+ else
|
|
|
|
+ if Pos('text/xml', FHTTP.Response.ContentType) > 0 then
|
|
|
|
+ begin
|
|
|
|
+ EditorContent.Highlighter := SynXMLSyn;
|
|
|
|
+ end
|
|
|
|
+ else
|
|
|
|
+ if Pos('text/html', FHTTP.Response.ContentType) > 0 then
|
|
|
|
+ begin
|
|
|
|
+ EditorContent.Highlighter := SynHTMLSyn;
|
|
|
|
+ end
|
|
|
|
+ else
|
|
|
|
+ begin
|
|
|
|
+ EditorContent.Highlighter := nil;
|
|
|
|
+ end;
|
|
|
|
|
|
|
|
+ EditorContent.SetFocus;
|
|
|
|
|
|
- dxStatusBar.Panels[1].Text := FormatFloat('Response Time: 0, ms', GetTickCount - tick);
|
|
|
|
- dxStatusBar.Panels[2].Text := 'Response Code: ' + HTTP.ResponseCode.ToString;
|
|
|
|
- Screen.Cursor := crDefault;
|
|
|
|
|
|
+
|
|
|
|
+ dxStatusBar.Panels[1].Text := FormatFloat('Response Time: 0, ms', GetTickCount - tick);
|
|
|
|
+ dxStatusBar.Panels[2].Text := 'Response Code: ' + FHTTP.ResponseCode.ToString;
|
|
|
|
+ Screen.Cursor := crDefault;
|
|
|
|
+ end;
|
|
|
|
+ finally
|
|
|
|
+ FHTTP.Free;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|