Ive проблема и я не могу понять, как я могу решить следующую проблему: Я бы хотел отправить несколько запросов http на ось. Вот мой код:отправить http-запросы, сохранить сессию вживую: C/C++ с cURL (axus camera)
#include <stdio.h>
#include <curl/curl.h>
int main(void)
{
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "http:/root:[email protected]");
/* example.com is redirected, so we tell libcurl to follow redirection */
// curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
res=curl_easy_perform(curl);
curl_easy_setopt(curl, CURLOPT_URL, "http:/IPADDRESS/axis-cgi/com/ptz.cgi?move=left");
/* Perform the request, res will get the return code */
res = curl_easy_perform(curl);
/* Check for errors */
if(res != CURLE_OK)
fprintf(stderr, "curl_easy_perform() failed: %s\n",
curl_easy_strerror(res));
/* always cleanup */
curl_easy_cleanup(curl);
}
return 0;
}
Все, что я хочу сделать в этом примере, чтобы сохранить свою сессию в живых после того, как вошли в IPaddress, а затем отправить заказ «шаг = влево» к этому очень IP-адрес. Когда я выполнить эту программу, я получил эти сообщения:
<HTML>
<HEAD>
<META HTTP-EQUIV="Expires" CONTENT="Tue, 01 Jan 1980 1:00:00 GMT">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<META HTTP-EQUIV="Refresh" CONTENT="0; URL=/view/index.shtml">
Your browser has JavaScript turned off.<br>For the user interface to work effectively, you must enable JavaScript in your browser and reload/refresh this page.
</noscript>
</HEAD>
<BODY>
</BODY>
</HTML>
<HTML><HEAD><TITLE>401 Unauthorized</TITLE></HEAD>
<BODY><H1>401 Unauthorized</H1>
Your client does not have permission to get URL /axis-cgi/com/ptz.cgi from this server.
</BODY></HTML>
Я предполагаю, что я не был даже вошли в IPaddress ...
Я никогда не использовал этот вид метода, прежде чем ... Вы можете помогите мне с этим?
Большое спасибо.
Похоже, что вы должны использовать ' curl_multi_ * 'и включить' CURLMOPT_PIPELINING'. Вам нужно зарегистрировать 'CURL *' с 'CURLM *'. Я нашел пример [здесь] (http://darcs.net/release/src/hscurl.c). – jxh