Sign in to follow this  
Followers 0
sjones

Returning HTTP Response/Status Codes with AutoIt

2 posts in this topic

Hello all,

I searched all over the place for example code that can return the HTTP Response/Status codes and couldn't find one anywhere. So.... I decided to write one myself. I hope a few others will find this helpful.

Dim $objhttp
Dim $httpstatus
Dim $CheckHTTPStatus
Dim $codetype
Dim $strURL = "http://www.autoitscript.com/"


CheckHttpStatus($strURL)
Func CheckHttpStatus($strActlURL)
    $objhttp = ObjCreate("MSXML2.XMLhttp.3.0") 
    $objhttp.Open("GET", $strActlURL, false) 

    $objhttp.Send 
    $httpstatus = $objhttp.Status
    If $httpstatus = "" Then
        $CheckHTTPStatus = "Error"
    Else
        $codetype = stringleft($httpstatus,1)
        If $codetype = 2 or $codetype = 3 Then
            $CheckHttpStatus = "Success"
        Else
            $CheckHttpStatus = "Error"
        EndIf
    EndIf
    
EndFunc

msgbox(0,"test",$httpstatus)

Cheers! SJones

1 person likes this

Share this post


Link to post
Share on other sites

Welcome to the forums!

That looks like the beginnings of a useful udf!

You might also want to reference this, I'm not sure if it's very good based on the comments, but I've often seen it referenced around here.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0