-
Notifications
You must be signed in to change notification settings - Fork 11
Description
Hi there,
Uncovered a need for the library to expose the TIdformField, specially when posting multi-part form. Here is the test case:
RestReq := TRestRequest.Create().Domain(Domain).Path(MethodPath);
params := TStringList.Create;
try
params.Add('someOne=' + someOne);
params.Add('someTwo=' + someTwo);
RestReq.FileParam('fil', fileNameWithPath);
RestReq.BeforeRequest := FOnBeforeReq;
RestReq.ConnectionTimeOut := TimeOut;
RestReq.ReadTimeOut := TimeOut;
RestResp := RestReq.Post(params);
if RestResp.ResponseCode = 200 then
when a value in a regular Name=Value parameter (and not the file param) is more than 71 characters, value is broken by "=CRLF" because the default content transfer is "quoted-printable".
One probable fix is(highlighted below), change the content transfer to BLANK after the form field is added:
function TRestRequest.createMultiPartFormDataStreamFromStringList(strings: TStringList;
aFileParams: TStringList): TIdMultiPartFormDataStream;
var
i: integer;
key, value: string;
begin
Result := TIdMultiPartFormDataStream.Create;
for i := 0 to strings.Count - 1 do
begin
key := strings.Names[i];
value := strings.ValueFromIndex[i];
Result.AddFormField(key, value).ContentTransfer := '';
end;
for i := 0 to aFileParams.Count - 1 do
begin
key := aFileParams.Names[i];
value := aFileParams.ValueFromIndex[i];
Result.AddFile(key, value, GetMIMETypeFromFile(value));
end;
end;