@@ -32,8 +32,8 @@ local POST_URL = "http://127.0.0.1:7090/post"
3232-- print("------------------------------------")
3333-- print("")
3434
35- local weak_ptr , gc_collect , is_curl_ge , read_file , stream , Stream =
36- utils .import (' weak_ptr' , ' gc_collect' , ' is_curl_ge' , ' read_file' , ' stream' , ' Stream' )
35+ local weak_ptr , gc_collect , is_curl_ge , read_file , stream , Stream , dump_request =
36+ utils .import (' weak_ptr' , ' gc_collect' , ' is_curl_ge' , ' read_file' , ' stream' , ' Stream' , ' dump_request ' )
3737
3838local ENABLE = true
3939
@@ -1026,4 +1026,38 @@ function test_chunk_end() test_cb('chunk_end_function') end
10261026
10271027end
10281028
1029+ local _ENV = TEST_CASE ' set_slist' if ENABLE then
1030+
1031+ local c
1032+
1033+ function teardown ()
1034+ if c then c :close () end
1035+ c = nil
1036+ end
1037+
1038+ function test_set ()
1039+ c = curl .easy ()
1040+ c :setopt_httpheader ({' X-Custom: value' })
1041+ local body , headers = assert_string (dump_request (c ))
1042+ assert_match (" X%-Custom:%s*value\r\n " , headers )
1043+ end
1044+
1045+ function test_unset ()
1046+ c = curl .easy ()
1047+ c :setopt_httpheader ({' X-Custom: value' })
1048+ c :unsetopt_httpheader ()
1049+ local body , headers = assert_string (dump_request (c ))
1050+ assert_not_match (" X%-Custom:%s*value\r\n " , headers )
1051+ end
1052+
1053+ function test_set_empty_array ()
1054+ c = curl .easy ()
1055+ c :setopt_httpheader ({' X-Custom: value' })
1056+ c :setopt_httpheader ({})
1057+ local body , headers = assert_string (dump_request (c ))
1058+ assert_not_match (" X%-Custom:%s*value\r\n " , headers )
1059+ end
1060+
1061+ end
1062+
10291063RUN ()
0 commit comments