Sample code for 30+ languages & platforms
Unicode C++

Example: Http.ExtractMetaRefreshUrl method

Demonstrates the ExtractMetaRefreshUrl method.

Chilkat Unicode C++ Downloads

Unicode C++
#include <CkHttpW.h>
#include <CkStringBuilderW.h>

void ChilkatSample(void)
    {
    bool success = false;

    CkHttpW http;

    //  Sample HTML with a META refresh.

    //  <!DOCTYPE html>
    //  <html lang="en">
    //  <head>
    //    <meta charset="utf-8" />
    //    <meta http-equiv="refresh" content="5; url=https://example.com" />
    //    <title>Meta Refresh Redirect</title>
    //  </head>
    //  <body>
    //    <p>Redirecting to example.com in 5 seconds�</p>
    //  </body>
    //  </html>

    CkStringBuilderW sb;
    bool bCrlf = true;
    sb.AppendLine(L"<!DOCTYPE html>",bCrlf);
    sb.AppendLine(L"<html lang=\"en\">",bCrlf);
    sb.AppendLine(L"<head>",bCrlf);
    sb.AppendLine(L"  <meta charset=\"utf-8\" />",bCrlf);
    sb.AppendLine(L"  <meta http-equiv=\"refresh\" content=\"5; url=https://example.com\" />",bCrlf);
    sb.AppendLine(L"  <title>Meta Refresh Redirect</title>",bCrlf);
    sb.AppendLine(L"</head>",bCrlf);
    sb.AppendLine(L"<body>",bCrlf);
    sb.AppendLine(L"  <p>Redirecting to example.com in 5 seconds�</p>",bCrlf);
    sb.AppendLine(L"</body>",bCrlf);
    sb.AppendLine(L"</html>",bCrlf);

    const wchar_t *url = http.extractMetaRefreshUrl(sb.getAsString());
    if (http.get_LastMethodSuccess() == false) {
        wprintf(L"The HTML has no META refresh tag.\n");
    }
    else {
        wprintf(L"META refresh URL: %s\n",url);
    }
    }