Skip to content

Commit f313487

Browse files
committed
fix --form erasing headers
1 parent 9961480 commit f313487

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

xidelbase.pas

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ TFollowTo = class
390390
THTTPRequest = class(TFollowTo)
391391
private
392392
variablesReplaced: boolean;
393+
procedure appendHeader(const h: string);
393394
public
394395
url: string;
395396
method: string;
@@ -1088,6 +1089,12 @@ function TDownload.clone(newparent: TProcessingContext): TDataProcessing;
10881089

10891090
{ THTTPRequest }
10901091

1092+
procedure THTTPRequest.appendHeader(const h: string);
1093+
begin
1094+
if header <> '' then header := header + #13#10;
1095+
header += h;
1096+
end;
1097+
10911098
constructor THTTPRequest.create(aurl: string);
10921099
begin
10931100
url := aurl;
@@ -1163,7 +1170,7 @@ procedure THTTPRequest.replaceVariables;
11631170
nvalue: String;
11641171
temp: String;
11651172
filename: String;
1166-
contenttype: String;
1173+
contenttype, boundary: String;
11671174
kind: Char;
11681175
t: Integer;
11691176
begin
@@ -1217,8 +1224,8 @@ procedure THTTPRequest.replaceVariables;
12171224
end;
12181225
mime.addFormData(name, nvalue, filename, contenttype, '');
12191226
end;
1220-
data := mime.compose(header);
1221-
header := TMIMEMultipartData.HeaderForBoundary(header);
1227+
data := mime.compose(boundary);
1228+
appendHeader(TMIMEMultipartData.HeaderForBoundary(boundary));
12221229
end;
12231230
begin
12241231
if variablesReplaced then exit; //this method is still supposed to be only called once
@@ -1256,12 +1263,9 @@ procedure THTTPRequest.readOptions(reader: TOptionReaderWrapper);
12561263
if reader is TOptionReaderFromObject then begin
12571264
variablesReplaced := true;
12581265
tempxq := xqvalue();
1259-
if reader.read('headers', tempxq) then begin
1260-
for h in tempxq do begin
1261-
if header <> '' then header := header + #13#10;
1262-
header += h.toString;
1263-
end;
1264-
end;
1266+
if reader.read('headers', tempxq) then
1267+
for h in tempxq do
1268+
appendHeader(h.toString);
12651269
end;
12661270
method:='GET';
12671271
if reader.read('post', data) then

0 commit comments

Comments
 (0)