1- // / Unit that contains everything related to Params from either the query request
1+ // / Unit that contains everything related to Params from either the query request
22// / or response.
33unit RALParams;
44
@@ -101,7 +101,8 @@ TRALParams = class
101101 function Encrypt (AStream: TStream): TStream;
102102
103103 // / Results either = or : if found on the input text.
104- function FindNameSeparator (const ASource: StringRAL): StringRAL;
104+ function FindHeaderNameSeparator (const ASource: StringRAL): StringRAL;
105+ function FindBodyNameSeparator (const ASource: StringRAL): StringRAL;
105106 function GetBody : TList;
106107 function GetParam (AIndex: IntegerRAL; AKind: TRALParamKind): TRALParam; overload;
107108 function GetParam (AIndex: IntegerRAL): TRALParam; overload;
@@ -136,6 +137,8 @@ TRALParams = class
136137 procedure AppendParams (ASource: TStringList; AKind: TRALParamKind); overload;
137138 // / Used to append a list of params (ASource) to the current params list.
138139 procedure AppendParams (ASource: TStrings; AKind: TRALParamKind); overload;
140+ // / Used to append a list of params (ASource) from the body to the current params list.
141+ procedure AppendBodyParams (ASource: TStrings; AKind: TRALParamKind);
139142 // / Used to append a list of params in a string to the current params list.
140143 procedure AppendParamsListText (ASource: StringRAL; AKind: TRALParamKind;
141144 ANameSeparator: StringRAL = ' ' );
@@ -626,7 +629,7 @@ procedure TRALParams.AppendParams(ASource: TStrings; AKind: TRALParamKind);
626629 vSeparator: StringRAL;
627630begin
628631 if ASource.Count > 0 then
629- vSeparator := FindNameSeparator (ASource.Strings[0 ]);
632+ vSeparator := FindHeaderNameSeparator (ASource.Strings[0 ]);
630633
631634 for vInt := 0 to Pred(ASource.Count) do
632635 AppendParamLine(ASource.Strings[vInt], vSeparator, AKind);
@@ -646,7 +649,7 @@ procedure TRALParams.AppendParamsListText(ASource: StringRAL; AKind: TRALParamKi
646649 { $ENDIF}
647650
648651 if (ASource <> ' ' ) and (ANameSeparator = ' ' ) then
649- ANameSeparator := FindNameSeparator (ASource);
652+ ANameSeparator := FindHeaderNameSeparator (ASource);
650653
651654 vLine := ' ' ;
652655 for vInt := POSINISTR to RALHighStr(ASource) do
@@ -1015,7 +1018,7 @@ procedure TRALParams.DecodeFields(const ASource: StringRAL; AKind: TRALParamKind
10151018begin
10161019 vStringList := URLEncodedToList(ASource);
10171020 try
1018- AppendParams (vStringList, AKind);
1021+ AppendBodyParams (vStringList, AKind);
10191022 finally
10201023 FreeAndNil(vStringList);
10211024 end ;
@@ -1161,7 +1164,25 @@ function TRALParams.NextParamStr: StringRAL;
11611164 Result := ' ral_param' + IntToStr(FNextParam);
11621165end ;
11631166
1164- function TRALParams.FindNameSeparator (const ASource: StringRAL): StringRAL;
1167+ function TRALParams.FindBodyNameSeparator (const ASource: StringRAL): StringRAL;
1168+ var
1169+ vPos, vMin: IntegerRAL;
1170+ begin
1171+ begin
1172+ vMin := Length(ASource);
1173+ vPos := Pos(' =' , ASource);
1174+ if (vPos > 0 ) and (vPos <= vMin) then
1175+ Result := ' ='
1176+ else
1177+ begin
1178+ vPos := Pos(StringRAL(' : ' ), ASource);
1179+ if (vPos > 0 ) and (vPos <= vMin) then
1180+ Result := ' : ' ;
1181+ end ;
1182+ end ;
1183+ end ;
1184+
1185+ function TRALParams.FindHeaderNameSeparator (const ASource: StringRAL): StringRAL;
11651186var
11661187 vPos, vMin: IntegerRAL;
11671188 Engine: StringRAL;
@@ -1187,6 +1208,18 @@ function TRALParams.FindNameSeparator(const ASource: StringRAL): StringRAL;
11871208 end ;
11881209end ;
11891210
1211+ procedure TRALParams.AppendBodyParams (ASource: TStrings; AKind: TRALParamKind);
1212+ var
1213+ vInt: Integer;
1214+ vSeparator: StringRAL;
1215+ begin
1216+ if ASource.Count > 0 then
1217+ vSeparator := FindBodyNameSeparator(ASource.Strings[0 ]);
1218+
1219+ for vInt := 0 to Pred(ASource.Count) do
1220+ AppendParamLine(ASource.Strings[vInt], vSeparator, AKind);
1221+ end ;
1222+
11901223procedure TRALParams.AppendParamLine (const ALine, ANameSeparator: StringRAL;
11911224 AKind: TRALParamKind);
11921225var
0 commit comments