【问题标题】:Get response from wicket ajax in web server Using Libcurl使用 Libcurl 从 Web 服务器中的 wicket ajax 获取响应
【发布时间】:2020-09-30 09:08:39
【问题描述】:

只是想知道 libcurl 是否能够从网页中的 wicket ajax 函数获得响应? 因为我想将文件上传到 Web 服务器,但需要在加载网页时接收参数。这是来自 wicket ajax 的 curl 命令/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>

【问题讨论】:

    标签: ajax wicket libcurl


    【解决方案1】:

    您的 curl_easy_xyz sn-p 中没有 JSESSIONID 的 Cookie。

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

    1601452951304 只是 jQuery 添加的时间戳(Wicket 在内部使用它)以使浏览器无法缓存请求。因此,您可以使用任何随机键/值对来代替它。

    【讨论】:

    • 是的,我已经在登录阶段获得了cookies,这只是一个连续的部分。哇太棒了!不知道我可以使用任何随机值。我会尽力让你知道。谢谢。
    猜你喜欢
    • 2015-02-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-18
    • 1970-01-01
    • 2016-08-21
    相关资源
    最近更新 更多