Changed FormField handling back to urlencoded format.
This commit is contained in:
parent
76cd385462
commit
be7615f7dc
|
@ -23,9 +23,7 @@ unit URestemplateApp;
|
||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, CustApp,
|
Classes, SysUtils, CustApp, IniFiles, jsonparser, JTemplate, UFilter, IdHTTP;
|
||||||
IniFiles, jsonparser, JTemplate,
|
|
||||||
UFilter, IdHTTP, IdMultipartFormData;
|
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
|
@ -55,7 +53,7 @@ type
|
||||||
FHttp: TRestHTTP;
|
FHttp: TRestHTTP;
|
||||||
FRequest: TRestRequest;
|
FRequest: TRestRequest;
|
||||||
FContent: TStringList;
|
FContent: TStringList;
|
||||||
FFormFields: TIdMultiPartFormDataStream;
|
FFormFields: TStrings;
|
||||||
FFilters: TFilterList;
|
FFilters: TFilterList;
|
||||||
FBeautify: Boolean;
|
FBeautify: Boolean;
|
||||||
FURL: String;
|
FURL: String;
|
||||||
|
@ -328,18 +326,10 @@ begin
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TRestemplateApplication.CmdFormField(AData: String);
|
procedure TRestemplateApplication.CmdFormField(AData: String);
|
||||||
var
|
|
||||||
i: Integer;
|
|
||||||
begin
|
begin
|
||||||
i := 1;
|
|
||||||
FParser.Content := AData;
|
FParser.Content := AData;
|
||||||
FParser.Replace;
|
FParser.Replace;
|
||||||
AData := FParser.Content;
|
FFormFields.Add(FParser.Content);
|
||||||
|
|
||||||
while (i < Length(AData)) and (AData[i] <> '=') do
|
|
||||||
Inc(i);
|
|
||||||
|
|
||||||
FFormFields.AddFormField(Copy(AData, 1, i - 1), Copy(AData, i + 1, Length(AData)));
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TRestemplateApplication.CmdProxy(AData: String);
|
procedure TRestemplateApplication.CmdProxy(AData: String);
|
||||||
|
@ -400,11 +390,9 @@ begin
|
||||||
FRequest.Prepare;
|
FRequest.Prepare;
|
||||||
FHttp.Request := FRequest;
|
FHttp.Request := FRequest;
|
||||||
FHttp.HTTPOptions := FHttp.HTTPOptions + [hoNoProtocolErrorException];
|
FHttp.HTTPOptions := FHttp.HTTPOptions + [hoNoProtocolErrorException];
|
||||||
if FFormFields.Size > 0 then
|
if SameText('POST', FMethod) and (FFormFields.Count > 0) then
|
||||||
begin
|
FHttp.Post(AURL, FFormFields, response)
|
||||||
FHttp.Request.ContentType := FFormFields.RequestContentType;
|
else
|
||||||
FHttp.Perform(FMethod, AURL, FFormFields, response);
|
|
||||||
end else
|
|
||||||
FHttp.Perform(FMethod, AURL, request, response);
|
FHttp.Perform(FMethod, AURL, request, response);
|
||||||
except
|
except
|
||||||
on E: Exception do
|
on E: Exception do
|
||||||
|
@ -559,7 +547,7 @@ begin
|
||||||
|
|
||||||
FSessionIni := TIniFile.Create(FConfigDir + 'session.ini');
|
FSessionIni := TIniFile.Create(FConfigDir + 'session.ini');
|
||||||
FContent := TStringList.Create;
|
FContent := TStringList.Create;
|
||||||
FFormFields := TIdMultiPartFormDataStream.Create;
|
FFormFields := TStringList.Create;
|
||||||
FHttp := TRestHTTP.Create(nil);
|
FHttp := TRestHTTP.Create(nil);
|
||||||
FRequest := TRestRequest.Create(FHttp);
|
FRequest := TRestRequest.Create(FHttp);
|
||||||
FRequest.RawHeaders.AddValue('User-Agent', 'Mozilla/4.0 (compatible; restemplate ' + VersionInfo.GetProductVersionString + ')');
|
FRequest.RawHeaders.AddValue('User-Agent', 'Mozilla/4.0 (compatible; restemplate ' + VersionInfo.GetProductVersionString + ')');
|
||||||
|
|
Loading…
Reference in New Issue