diff --git a/URestemplateApp.pas b/URestemplateApp.pas index 204b8e2..0ddf7e7 100644 --- a/URestemplateApp.pas +++ b/URestemplateApp.pas @@ -23,9 +23,7 @@ unit URestemplateApp; interface uses - Classes, SysUtils, CustApp, - IniFiles, jsonparser, JTemplate, - UFilter, IdHTTP, IdMultipartFormData; + Classes, SysUtils, CustApp, IniFiles, jsonparser, JTemplate, UFilter, IdHTTP; type @@ -55,7 +53,7 @@ type FHttp: TRestHTTP; FRequest: TRestRequest; FContent: TStringList; - FFormFields: TIdMultiPartFormDataStream; + FFormFields: TStrings; FFilters: TFilterList; FBeautify: Boolean; FURL: String; @@ -328,18 +326,10 @@ begin end; procedure TRestemplateApplication.CmdFormField(AData: String); -var - i: Integer; begin - i := 1; FParser.Content := AData; FParser.Replace; - AData := 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))); + FFormFields.Add(FParser.Content); end; procedure TRestemplateApplication.CmdProxy(AData: String); @@ -400,11 +390,9 @@ begin FRequest.Prepare; FHttp.Request := FRequest; FHttp.HTTPOptions := FHttp.HTTPOptions + [hoNoProtocolErrorException]; - if FFormFields.Size > 0 then - begin - FHttp.Request.ContentType := FFormFields.RequestContentType; - FHttp.Perform(FMethod, AURL, FFormFields, response); - end else + if SameText('POST', FMethod) and (FFormFields.Count > 0) then + FHttp.Post(AURL, FFormFields, response) + else FHttp.Perform(FMethod, AURL, request, response); except on E: Exception do @@ -559,7 +547,7 @@ begin FSessionIni := TIniFile.Create(FConfigDir + 'session.ini'); FContent := TStringList.Create; - FFormFields := TIdMultiPartFormDataStream.Create; + FFormFields := TStringList.Create; FHttp := TRestHTTP.Create(nil); FRequest := TRestRequest.Create(FHttp); FRequest.RawHeaders.AddValue('User-Agent', 'Mozilla/4.0 (compatible; restemplate ' + VersionInfo.GetProductVersionString + ')');