@@ -6,6 +6,7 @@ interface
66
77uses
88 Classes, SysUtils, TypInfo,
9+ RALHashes,
910 RALTypes, RALMIMETypes, RALMultipartCoder, RALTools, RALUrlCoder,
1011 RALCripto, RALCriptoAES, RALStream, RALCompress, RALConsts;
1112
@@ -20,6 +21,7 @@ TRALParam = class
2021 private
2122 FContent: TStream;
2223 FContentType: StringRAL;
24+ FContentDisposition: StringRAL;
2325 FContentDispositionInline: Boolean;
2426 FFileName: StringRAL;
2527 FKind: TRALParamKind;
@@ -221,7 +223,7 @@ implementation
221223
222224procedure TRALParam.Clone (ASource: TRALParam);
223225begin
224- ASource.ContentDisposition := Self.ContentDisposition ;
226+ ASource.ContentDispositionInline := Self.ContentDispositionInline ;
225227 ASource.ContentType := Self.ContentType;
226228 ASource.FileName := Self.FileName;
227229 ASource.Kind := Self.Kind;
@@ -318,7 +320,9 @@ function TRALParam.GetContentDisposition: StringRAL;
318320 if (FFileName <> ' ' ) and (not FContentDispositionInline) then
319321 Result := Format(' attachment; name="%s"; filename="%s"' , [FParamName, FFileName])
320322 else
321- Result := Format(' inline; name="%s"' , [FParamName]);
323+ // Result := Format('inline; name="%s"', [FParamName]);
324+ // pode cagar o módulo web
325+ Result := ' inline' ;
322326end ;
323327
324328function TRALParam.GetContentSize : Int64RAL;
@@ -443,7 +447,7 @@ procedure TRALParam.SetContentDisposition(AValue: StringRAL);
443447 vQuoted := False;
444448 for vInt := 1 to vLen do
445449 begin
446- vChr := Char (AStr[vInt]);
450+ vChr := CharRAL (AStr[vInt]);
447451 if (vChr = ' "' ) then
448452 begin
449453 vQuoted := not vQuoted;
@@ -531,13 +535,13 @@ function TRALParams.AddFile(const AParamName, AFileName: StringRAL): TRALParam;
531535 Result.OpenFile(AFileName);
532536 Result.Kind := rpkBODY;
533537
534- vMime := TRALMIMEType.Create ;
538+ vMime := TRALMIMEType.GetInstance ;
535539 try
536540 Result.ContentType := vMime.GetMIMEType(AFileName);
537541 if Result.ContentType = ' ' then
538542 Result.ContentType := rctAPPLICATIONOCTETSTREAM;
539543 finally
540- FreeAndNil(vMime);
544+ // FreeAndNil(vMime);
541545 end ;
542546 end ;
543547end ;
@@ -635,9 +639,12 @@ procedure TRALParams.AppendParamsListText(ASource: StringRAL; AKind: TRALParamKi
635639 vLine: StringRAL;
636640 vIs13: Boolean;
637641begin
638- { $IFNDEF FPC}
639- ASource := UTF8ToString(ASource);
642+ { $IFDEF FPC}
643+ ASource := UTF8Decode(ASource);
644+ { $ELSE}
645+ ASource := UTF8ToString(ASource);
640646 { $ENDIF}
647+
641648 if (ASource <> ' ' ) and (ANameSeparator = ' ' ) then
642649 ANameSeparator := FindNameSeparator(ASource);
643650
@@ -1157,16 +1164,26 @@ function TRALParams.NextParamStr: StringRAL;
11571164function TRALParams.FindNameSeparator (const ASource: StringRAL): StringRAL;
11581165var
11591166 vPos, vMin: IntegerRAL;
1167+ Engine: StringRAL;
11601168begin
1161- vMin := Length(ASource);
1162- vPos := Pos(' =' , ASource);
1163- if (vPos > 0 ) and (vPos <= vMin) then
1169+ Engine := Self.GetParam(' RALEngine' ).AsString;
1170+ if SameText(Engine, ENGINESYNOPSE) then
1171+ Result := ' : '
1172+ else if SameText(Engine, ENGINEINDY) or SameText(Engine, ENGINEFPHTTP)
1173+ or SameText(Engine, ENGINESAGUI) or SameText(Engine, ENGINENETHTTP) then
11641174 Result := ' ='
11651175 else
11661176 begin
1167- vPos := Pos(StringRAL(' : ' ), ASource);
1177+ vMin := Length(ASource);
1178+ vPos := Pos(' =' , ASource);
11681179 if (vPos > 0 ) and (vPos <= vMin) then
1169- Result := ' : ' ;
1180+ Result := ' ='
1181+ else
1182+ begin
1183+ vPos := Pos(StringRAL(' : ' ), ASource);
1184+ if (vPos > 0 ) and (vPos <= vMin) then
1185+ Result := ' : ' ;
1186+ end ;
11701187 end ;
11711188end ;
11721189
@@ -1254,34 +1271,35 @@ function TRALParams.Compress(AStream: TStream): TStream;
12541271end ;
12551272
12561273function TRALParams.Encrypt (AStream: TStream): TStream;
1257- var
1258- vCript: TRALCripto;
1259- begin
1260- Result := nil ;
1261- case FCriptoOptions.CriptType of
1262- crAES128:
1263- begin
1264- vCript := TRALCriptoAES.Create;
1265- TRALCriptoAES(vCript).AESType := tAES128;
1266- end ;
1267- crAES192:
1268- begin
1269- vCript := TRALCriptoAES.Create;
1270- TRALCriptoAES(vCript).AESType := tAES192;
1271- end ;
1272- crAES256:
1273- begin
1274- vCript := TRALCriptoAES.Create;
1275- TRALCriptoAES(vCript).AESType := tAES256;
1276- end ;
1277- end ;
1278-
1279- try
1280- vCript.Key := FCriptoOptions.Key;
1281- Result := vCript.EncryptAsStream(AStream);
1282- finally
1283- FreeAndNil(vCript);
1284- end ;
1274+ // var
1275+ // vCript: TRALCripto;
1276+ begin
1277+ Result := TRALHashes.Encrypt(AStream, FCriptoOptions.Key, FCriptoOptions.CriptType);
1278+ // Result := nil;
1279+ // case FCriptoOptions.CriptType of
1280+ // crAES128:
1281+ // begin
1282+ // vCript := TRALCriptoAES.Create;
1283+ // TRALCriptoAES(vCript).AESType := tAES128;
1284+ // end;
1285+ // crAES192:
1286+ // begin
1287+ // vCript := TRALCriptoAES.Create;
1288+ // TRALCriptoAES(vCript).AESType := tAES192;
1289+ // end;
1290+ // crAES256:
1291+ // begin
1292+ // vCript := TRALCriptoAES.Create;
1293+ // TRALCriptoAES(vCript).AESType := tAES256;
1294+ // end;
1295+ // end;
1296+ //
1297+ // try
1298+ // vCript.Key := FCriptoOptions.Key;
1299+ // Result := vCript.EncryptAsStream(AStream);
1300+ // finally
1301+ // FreeAndNil(vCript);
1302+ // end;
12851303end ;
12861304
12871305function TRALParams.Decompress (AStream: TStream): TStream;
@@ -1327,65 +1345,65 @@ function TRALParams.Decompress(const ASource: StringRAL): StringRAL;
13271345end ;
13281346
13291347function TRALParams.Decrypt (AStream: TStream): TStream;
1330- var
1331- vCript: TRALCripto;
1332- begin
1333- Result := nil ;
1334- case FCriptoOptions.CriptType of
1335- crAES128:
1336- begin
1337- vCript := TRALCriptoAES.Create;
1338- TRALCriptoAES(vCript).AESType := tAES128;
1339- end ;
1340- crAES192:
1341- begin
1342- vCript := TRALCriptoAES.Create;
1343- TRALCriptoAES(vCript).AESType := tAES192;
1344- end ;
1345- crAES256:
1346- begin
1347- vCript := TRALCriptoAES.Create;
1348- TRALCriptoAES(vCript).AESType := tAES256;
1349- end ;
1350- end ;
1351-
1352- try
1353- vCript.Key := FCriptoOptions.Key;
1354- Result := vCript.DecryptAsStream(AStream);
1355- finally
1356- FreeAndNil(vCript);
1357- end ;
1348+ // var
1349+ // vCript: TRALCripto;
1350+ begin
1351+ Result := TRALHashes.Decrypt(AStream, FCriptoOptions.Key, FCriptoOptions.CriptType) ;
1352+ // case FCriptoOptions.CriptType of
1353+ // crAES128:
1354+ // begin
1355+ // vCript := TRALCriptoAES.Create;
1356+ // TRALCriptoAES(vCript).AESType := tAES128;
1357+ // end;
1358+ // crAES192:
1359+ // begin
1360+ // vCript := TRALCriptoAES.Create;
1361+ // TRALCriptoAES(vCript).AESType := tAES192;
1362+ // end;
1363+ // crAES256:
1364+ // begin
1365+ // vCript := TRALCriptoAES.Create;
1366+ // TRALCriptoAES(vCript).AESType := tAES256;
1367+ // end;
1368+ // end;
1369+ //
1370+ // try
1371+ // vCript.Key := FCriptoOptions.Key;
1372+ // Result := vCript.DecryptAsStream(AStream);
1373+ // finally
1374+ // FreeAndNil(vCript);
1375+ // end;
13581376end ;
13591377
13601378function TRALParams.Decrypt (const ASource: StringRAL): StringRAL;
1361- var
1362- vCript: TRALCripto;
1363- begin
1364- Result := ' ' ;
1365- case FCriptoOptions.CriptType of
1366- crAES128:
1367- begin
1368- vCript := TRALCriptoAES.Create;
1369- TRALCriptoAES(vCript).AESType := tAES128;
1370- end ;
1371- crAES192:
1372- begin
1373- vCript := TRALCriptoAES.Create;
1374- TRALCriptoAES(vCript).AESType := tAES192;
1375- end ;
1376- crAES256:
1377- begin
1378- vCript := TRALCriptoAES.Create;
1379- TRALCriptoAES(vCript).AESType := tAES256;
1380- end ;
1381- end ;
1382-
1383- try
1384- vCript.Key := FCriptoOptions.Key;
1385- Result := vCript.Decrypt(ASource);
1386- finally
1387- FreeAndNil(vCript);
1388- end ;
1379+ // var
1380+ // vCript: TRALCripto;
1381+ begin
1382+ Result := TRALHashes.Decrypt(ASource, FCriptoOptions.Key, FCriptoOptions.CriptType) ;
1383+ // case FCriptoOptions.CriptType of
1384+ // crAES128:
1385+ // begin
1386+ // vCript := TRALCriptoAES.Create;
1387+ // TRALCriptoAES(vCript).AESType := tAES128;
1388+ // end;
1389+ // crAES192:
1390+ // begin
1391+ // vCript := TRALCriptoAES.Create;
1392+ // TRALCriptoAES(vCript).AESType := tAES192;
1393+ // end;
1394+ // crAES256:
1395+ // begin
1396+ // vCript := TRALCriptoAES.Create;
1397+ // TRALCriptoAES(vCript).AESType := tAES256;
1398+ // end;
1399+ // end;
1400+ //
1401+ // try
1402+ // vCript.Key := FCriptoOptions.Key;
1403+ // Result := vCript.Decrypt(ASource);
1404+ // finally
1405+ // FreeAndNil(vCript);
1406+ // end;
13891407end ;
13901408
13911409procedure TRALParams.DelParam (const AName: StringRAL; AKind: TRALParamKind);
0 commit comments