问题遇到的现象和发生背景
使用libcurl C删除 cute http file server上指定的文件总是报错 403
问题相关代码,请勿粘贴截图
在CHORME上抓包删除一个hello的文件获取到如下信息:
curl "http://192.168.3.212/chfs/rmfiles%22 ^
-X "DELETE" ^
-H "Accept: /" ^
-H "Accept-Language: zh-CN,zh;q=0.9" ^
-H "Connection: keep-alive" ^
-H "Content-Type: multipart/form-data; boundary=--WebKitFormBoundary2g3sg8mEYkNlIDja" ^
-H "Cookie: JWT=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2MiOiJhYWEiLCJleHAiOjE2NjE4Mzg1MTh9.W32rUbKDO60o10BfJwf7UD9cLtUcRIrXAzTVfrBQj6Y; user=user" ^
-H "Origin: http://192.168.3.212" ^
-H "Referer: http://192.168.3.212/%22 ^
-H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36" ^
-H "cache-control: no-cache" ^
-data-raw ^"-WebKitFormBoundary2g3sg8mEYkNlIDja^
Content-Disposition: form-data; name=^^"filepath^^"^
^
/hello^
-WebKitFormBoundary2g3sg8mEYkNlIDja--^
^" ^
-compressed ^
-insecure &
curl "http://192.168.3.212/chfs/files?filepath=&_=1661836620731%22 ^
-H "Accept: /" ^
-H "Accept-Language: zh-CN,zh;q=0.9" ^
-H "Connection: keep-alive" ^
-H "Cookie: JWT=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2MiOiJhYWEiLCJleHAiOjE2NjE4Mzg1MTh9.W32rUbKDO60o10BfJwf7UD9cLtUcRIrXAzTVfrBQj6Y; user=user" ^
-H "Referer: http://192.168.3.212/%22 ^
-H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36" ^
-H "cache-control: no-cache" ^
--compressed ^
--insecure
我的解答思路和尝试过的方法
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
/* This is just the server URL */
curl_easy_setopt(curl, CURLOPT_URL, "http://192.168.3.212/chfs/rmfiles");
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "user=user&pwd=123&filepath=/haha");
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "DELETE");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
/* Perform the custom request */
res = curl_easy_perform(curl);
我尝试使用如下的语句来模拟操作,得到错误403
我想要达到的结果
各位,怎么样修改我的程序才可以达到抓包的效果?
或者谁有比较全面的delete用法说明的资料,麻烦提供一份,谢谢。