Как проверить, является ли веб-сайт http или https, с помощью кода C / C ++ с использованием библиотеки CURLPP?

После многого исследования в Google, я могу отправить запрос http через код c ++, используя библиотеку curlpp, и я получаю ответ, как показано ниже:

выход:

# g++ -o Curlpp Curlpp.C -lcurlpp
#./Curlpp
inside try:
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="https://mail.google.com/mail/">here</A>.
</BODY></HTML>

Но я хочу хранить только https://mail.google.com/mail/ часть в переменной. Как я могу это сделать?

программа:

#include <iostream>
#include <curlpp/cURLpp.hpp>
#include <curlpp/Easy.hpp>
#include <curlpp/Options.hpp>

using namespace cURLpp ; // notice the uppercase
using namespace Options ; // notice the uppercase
using namespace std ;

int main( int , char ** )
{

try
{
cout << "inside try: " << endl;
/* Our request to be sent */
Easy myRequest ;

/* Set the options */
myRequest.setOpt( Url( "gmail.com" ) ) ;

/* Perform request */
myRequest.perform( ) ;

}
catch ( RuntimeError & e )
{
cout << "inside RuntimeError & e: " << endl;
cout << e.what( ) << endl ;
}
catch ( LogicError & e )
{
cout << "inside LogicError & e: " << endl;
cout << e.what( ) << endl ;
}

return 0 ;
}

-5

Решение

Ударьте его HTTP-вызовом и увидите ответ 2xx. Затем нажмите на него по HTTPS-вызову и посмотрите, равен ли ответ 2xx.

0

Другие решения