Sample code for 30+ languages & platforms
DataFlex

Example: Http.ExtractMetaRefreshUrl method

Demonstrates the ExtractMetaRefreshUrl method.

Chilkat DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoHttp
    Handle hoSb
    Boolean iBCrlf
    String sUrl
    String sTemp1
    Boolean bTemp1

    Move False To iSuccess

    Get Create (RefClass(cComChilkatHttp)) To hoHttp
    If (Not(IsComObjectCreated(hoHttp))) Begin
        Send CreateComObject of hoHttp
    End

    // 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>

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSb
    If (Not(IsComObjectCreated(hoSb))) Begin
        Send CreateComObject of hoSb
    End
    Move True To iBCrlf
    Get ComAppendLine Of hoSb "<!DOCTYPE html>" iBCrlf To iSuccess
    Get ComAppendLine Of hoSb '<html lang="en">' iBCrlf To iSuccess
    Get ComAppendLine Of hoSb "<head>" iBCrlf To iSuccess
    Get ComAppendLine Of hoSb '  <meta charset="utf-8" />' iBCrlf To iSuccess
    Get ComAppendLine Of hoSb '  <meta http-equiv="refresh" content="5; url=https://example.com" />' iBCrlf To iSuccess
    Get ComAppendLine Of hoSb "  <title>Meta Refresh Redirect</title>" iBCrlf To iSuccess
    Get ComAppendLine Of hoSb "</head>" iBCrlf To iSuccess
    Get ComAppendLine Of hoSb "<body>" iBCrlf To iSuccess
    Get ComAppendLine Of hoSb "  <p>Redirecting to example.com in 5 seconds�</p>" iBCrlf To iSuccess
    Get ComAppendLine Of hoSb "</body>" iBCrlf To iSuccess
    Get ComAppendLine Of hoSb "</html>" iBCrlf To iSuccess

    Get ComGetAsString Of hoSb To sTemp1
    Get ComExtractMetaRefreshUrl Of hoHttp sTemp1 To sUrl
    Get ComLastMethodSuccess Of hoHttp To bTemp1
    If (bTemp1 = False) Begin
        Showln "The HTML has no META refresh tag."
    End
    Else Begin
        Showln "META refresh URL: " sUrl
    End



End_Procedure