@@ -130,19 +130,20 @@ interface
130130 function GetResponseCode : longint;
131131
132132 // / Makes an exact copy, e.g. for multithreading.
133+ // / @warning Receiver, sender and header streams will be shared,
134+ // / but not auto-destroyed. Form, together with its streams,
135+ // / will be shared. So it is wise to replace all streams with unique
136+ // / copies for each clone.
137+ // / @warning String lists assigned via SetXXX are shared and,
138+ // / as they are ref-counted, destroyed when the last reference
139+ // / disappears. For large objects assigned via SetOpt the programmer
140+ // / should bother about destruction for himself.
133141 function Clone : ICurl;
134142
135143 property Form : ICurlForm read GetForm write SetForm;
136144 end ;
137145
138146 TEasyCurlImpl = class (TInterfacedObject, ICurl)
139- private
140- type
141- TSListEntry = record
142- str : RawByteString;
143- entry : TCurlSList;
144- end ;
145- OaSListEntry = array of TSListEntry;
146147 private
147148 fHandle : TCurlHandle;
148149 fCustomHeaders, fPostQuote, fTelnetOptions, fPreQuote,
@@ -290,6 +291,9 @@ constructor ECurlError.Create(aObject : TEasyCurlImpl; aCode : TCurlCode);
290291constructor TEasyCurlImpl.Create;
291292begin
292293 inherited ;
294+ fSendStream.Init;
295+ fRecvStream.Init;
296+ fHeaderStream.Init;
293297 fHandle := curl_easy_init;
294298 if fHandle = nil then
295299 raise ECurlInternal.Create(' [TEasyCurlImpl.Create] Cannot create cURL object.' );
@@ -298,12 +302,24 @@ constructor TEasyCurlImpl.Create;
298302constructor TEasyCurlImpl.Create(aSource : TEasyCurlImpl);
299303begin
300304 inherited Create;
301- fSendStream.Init;
302- fRecvStream.Init;
303- fHeaderStream.Init;
305+ // Streams
306+ fSendStream.InitFrom(aSource.fSendStream);
307+ fRecvStream.InitFrom(aSource.fRecvStream);
308+ fHeaderStream.InitFrom(aSource.fHeaderStream);
309+ // Handle
304310 fHandle := curl_easy_duphandle(aSource.fHandle);
305311 if fHandle = nil then
306312 raise ECurlInternal.Create(' [TEasyCurlImpl.Create(TEasyCurlImpl)] Cannot clone cURL object.' );
313+ // Copy settings!
314+ fForm := aSource.fForm;
315+ fCustomHeaders := aSource.fCustomHeaders;
316+ fPostQuote := aSource.fPostQuote;
317+ fTelnetOptions := aSource.fTelnetOptions;
318+ fPreQuote := aSource.fPreQuote;
319+ fHttp200Aliases := aSource.fHttp200Aliases;
320+ fMailRcpt := aSource.fMailRcpt;
321+ fResolveList := aSource.fResolveList;
322+ fProxyHeader := aSource.fProxyHeader;
307323end ;
308324
309325destructor TEasyCurlImpl.Destroy;
0 commit comments