使用 Libcurl 从 Web 服务器中的 wicket ajax 获取响应

Get response from wicket ajax in web server Using Libcurl

只是想知道 libcurl 是否能够从网页中的 wicket ajax 函数获得响应? 因为我想将文件上传到网络服务器,但需要在加载网页时接收的参数。这是 wicket ajax;

的 curl command/url 响应
curl "https://192.168.10.167/ui/backup/upload?3-2.IBehaviorListener.0-resumableUploadPanel-storageFile-0-item~status-status~container^&_=1601452951304" -H "Connection: keep-alive" -H "Accept: application/xml, text/xml, */*; q=0.01" -H "X-Requested-With: XMLHttpRequest" -H "Wicket-Ajax-BaseURL: backup/upload?3" -H "Wicket-Ajax: true" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.70 Safari/537.36" -H "Sec-Fetch-Site: same-origin" -H "Sec-Fetch-Mode: cors" -H "Referer: https://192.168.10.167/ui/backup/upload?3" -H "Accept-Encoding: gzip, deflate, br" -H "Accept-Language: en-US,en;q=0.9" -H "Cookie: JSESSIONID=7D6307648979389393C" --compressed --insecure &

我需要的是1601452951304.

我尝试进入该页面,输入重定向命令并使用以下代码检索重定向 url:

curl_easy_setopt(curl, CURLOPT_URL,"https://192.168.10.167/ui/backup/upload");
curl_easy_setopt(curl, CURLOPT_HEADER, "Accept: application/xml, text/xml, */*; q=0.01");
curl_easy_setopt(curl, CURLOPT_ENCODING, "gzip, deflate, br");
curl_easy_setopt(curl, CURLOPT_HEADER, "Accept-Language: en-US,en;q=0.9");
curl_easy_setopt(curl, CURLOPT_HEADER, "Connection: keep-alive");
curl_easy_setopt(curl, CURLOPT_HEADER, "Host: 192.168.10.167");
curl_easy_setopt(curl, CURLOPT_HEADER, "Sec-Fetch-Mode: cors");
curl_easy_setopt(curl, CURLOPT_HEADER, "Sec-Fetch-Site: same-origin");
curl_easy_setopt(curl, CURLOPT_HEADER, "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.70 Safari/537.36");https://192.168.10.167/ui/backup/upload?7");

curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
res = curl_easy_perform(curl);
if(res == CURLE_OK) {
    char *url = NULL;
    curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &url);
    if(url)
      printf("Redirect to: %s\n", url);
  } 

但收到这些错误:

这是我在生成 url:

的网页中找到的函数
</script>
<script type="text/javascript" >
/*<![CDATA[*/
Wicket.Event.add(window, "load", function(event) { 
Wicket.Timer.set('ide', function(){Wicket.Ajax.ajax({"u":"./upload?3-3.IBehaviorListener.0-resumableUploadPanel-storageFile-0-item~status-status~container","c":"ide"});}, 1000);;
Wicket.Timer.set('id7', function(){Wicket.Ajax.ajax({"u":"./upload?3-3.IBehaviorListener.0-resumableUploadPanel-agentRegisterCheck","c":"id7"});}, 5000);;
;});
/*]]>*/
</script>

您的 curl_easy_xyz 代码段中没有 JSESSIONID 的 Cookie。

Wicket Ajax 通常使页面有状态,从而绑定一个 http 会话。

1601452951304 只是 jQuery 添加的时间戳(Wicket 在内部使用它)以通过浏览器发出请求 non-cacheable。所以你可以使用任何随机 key/value 对来代替它。