Jump to content
Sign in to follow this  

Returning HTTP Response/Status Codes with AutoIt

Recommended Posts

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

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

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


Cheers! SJones

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...