File tree Expand file tree Collapse file tree 2 files changed +56
-3
lines changed Expand file tree Collapse file tree 2 files changed +56
-3
lines changed Original file line number Diff line number Diff line change @@ -889,16 +889,16 @@ function test_reset()
889889 do
890890 local form = curl .form ()
891891 e = curl .easy {httppost = form }
892- pfrom = weak_ptr (form )
892+ pform = weak_ptr (form )
893893 end
894894
895895 gc_collect ()
896- assert (pfrom .value )
896+ assert (pform .value )
897897
898898 assert_equal (e , e :reset ())
899899
900900 gc_collect ()
901- assert (not pfrom .value )
901+ assert (not pform .value )
902902end
903903
904904end
Original file line number Diff line number Diff line change @@ -207,6 +207,27 @@ function test_mimepost_does_not_ref_to_easy()
207207 assert_nil (peasy .value )
208208end
209209
210+ function test_cleanup_on_easy_reset ()
211+
212+ local mime do
213+ mime = weak_ptr (easy :mime ())
214+ easy :setopt_mimepost (mime .value )
215+ end
216+
217+ gc_collect ()
218+
219+ assert_not_nil (mime .value )
220+
221+ easy :reset ()
222+
223+ gc_collect (10 )
224+
225+ assert_nil (mime .value )
226+
227+ easy :setopt {url = GET_URL , writefunction = function () end }
228+ easy :perform ()
229+ end
230+
210231end
211232
212233local _ENV = TEST_CASE ' mime basic' if not curl .OPT_MIMEPOST then
@@ -573,6 +594,38 @@ function test_pass_args()
573594 assert_match (' Content%-Transfer%-Encoding:%s*base64' , info )
574595end
575596
597+ local function easy_dump_mime (easy , mime , url )
598+ assert (mime :addpart {
599+ data = ' hello' ;
600+ encoder = ' base64' ;
601+ name = ' test' ;
602+ filename = ' test.html' ;
603+ type = ' test/html' ;
604+ headers = {
605+ ' X-Custom-Header: hello' ;
606+ }
607+ })
608+
609+ easy :setopt {
610+ mimepost = mime ;
611+ }
612+
613+ assert (easy :setopt {
614+ url = GET_URL ;
615+ customrequest = " GET" ;
616+
617+ writefunction = function ()end ;
618+ })
619+
620+ if not ok then return nil , err end
621+
622+ ok , err = easy :perform ()
623+
624+ if not ok then return nil , err end
625+
626+ return table.concat (buffer )
627+ end
628+
576629end
577630
578631RUN ()
You can’t perform that action at this time.
0 commit comments