HTTP status code checker

By _Dean_ on Feb 21, 2011

sometimes when you do a socket, and it returns a HTTP status code, and you dont understand what it really means you can use

• go to mIRC and press alt+r
• click on file, then new, and paste it into a new remote page

!checkstatus N

where N is a number

example

[18:48:32] <~Dean> !checkstatus 100
[18:48:36] <&Botname> 100 Continue - This means that the server has received the request headers, and that the client should proceed to send the request body (in case of a request which needs to be sent; for example, a POST request). If the request body is large, sending it to a server when a request has already been rejected based upon inappropriate headers is inefficient. To have a server check if the request
[18:48:37] <&Botname> could be accepted based on the requests headers alone, a client must send Expect: 100-continue as a header in its initial request (see RFC 2616 14.20 Expect header) and check if a 100 Continue status code is received in response before continuing (or receive 417 Expectation Failed and not continue).

it dont have a Flood protection, i made it to receive many requests at same time

on $*:text:/^!checkstatus\s(\d+)$/iS:#:{
  checkstatus $regml(1) #
}
alias checkstatus {
  var %x = $+(status,$ticks,$nick)
  if ($sock(%x)) { return }
  else {
    sockopen %x www.askapache.com 80
    sockmark %x $1|msg $2
  }
}

on *:sockopen:status*: { 
  if ($sockerr) { $gettok($sock($sockname).mark,2,124) ERROR: $sock($sockname).wsmsg | return }
  else {
    var %x sockwrite -n $sockname
    %x GET /htaccess/apache-status-code-headers-errordocument.html HTTP/1.1
    %x HOST: www.askapache.com
    %x
  }
}

on *:sockread:status*: { 
  tokenize 124 $sock($sockname).mark
  if ($sockerr) { $2 ERROR: $sock($sockname).wsmsg | return }
  else {
    var %x 
    sockread %x
    var %t = $regex(%x,/<a href="#status- $+ $1 $+ \b".+>Sample\s(.+)<\/a>\s<br \/>(.+)<\/dd>/)
    if (%t) {
      $2 $+(,$regml(1),) - $regsubex($regml(2),/<[^>]+>/g,)
      sockclose $sockname
    }
  }
  if (</table> isin %x) && (!%t) { 
    $2 The status code does not exist, or can not be found | sockclose $sockname
  }
}

Comments

Sign in to comment.
_Dean_   -  Feb 21, 2011

Thanks for score Jethro_

 Respond  
_Dean_   -  Feb 21, 2011

Jethro_ probably, this socket, takes 3 seconds to get an positive answer, and 4 seconds to get the error message
we never know what can happen in 3 seconds, since the website, can get online again in this time
i know, its a few seconds

Thanks for the score Scakk

 Respond  
Jethro   -  Feb 21, 2011

The return after an error check is purposeless. I rate you a 7 for its usefulness to lazy people.

 Respond  
Scakk   -  Feb 21, 2011

That version works fine. Now the other one is working _ No idea what is going on :(

Either way it is nead and handy for lazy people as me so I gave it a 7.

 Respond  
_Dean_   -  Feb 21, 2011

i need to test it into 6.35 so, and check if there is an error on it, so i will warn ppl about the version
i know that the same ppl as ever will score it with 1

try this edit

on $*:text:/^!checkstatus\s(\d+)$/iS:#:{
  checkstatus $regml(1) #
}
alias checkstatus {
  var %x = $+(status,$ticks,$nick)
  if ($sock(%x)) { return }
  else {
    sockopen %x www.askapache.com 80
    sockmark %x $1 $2
  }
}

on *:sockopen:status*: { 
  if ($sockerr) { $gettok($sock($sockname).mark,2,124) ERROR: $sock($sockname).wsmsg | return }
  else {
    var %x sockwrite -n $sockname
    %x GET /htaccess/apache-status-code-headers-errordocument.html HTTP/1.1
    %x HOST: www.askapache.com
    %x
  }
}

on *:sockread:status*: { 
  tokenize 32 $sock($sockname).mark
  if ($sockerr) { $2 ERROR: $sock($sockname).wsmsg | return }
  else {
    var %x 
    sockread %x
    var %t = $regex(%x,/<a href="#status- $+ $1 $+ \b".+>Sample\s(.+)<\/a>\s<br \/>(.+)<\/dd>/)
    if (%t) {
      msg $2 $+(,$regml(1),) - $regsubex($regml(2),/<[^>]+>/g,)
      sockclose $sockname
    }
  }
  if (</table> isin %x) && (!%t) { 
    msg $2 The status code does not exist, or can not be found | sockclose $sockname
  }
}
 Respond  
Scakk   -  Feb 21, 2011

I still use 6.35 so maybe a version issue.

Either handy snippet for lazy people as myself.

Notes he did not rate it a 1 as he has not even rated it

 Respond  
_Dean_   -  Feb 21, 2011

i dont know why, tested it into a new remote page, with mIRC 7.14 and worked well

 Respond  
Scakk   -  Feb 21, 2011

I did test it out and it broke. guess it hates me :P

 Respond  
_Dean_   -  Feb 21, 2011

its not needed the space Scakk since the "|" will be evaluated as the character that separates all toks
on tokenize, test it and you will see it

 Respond  
Scakk   -  Feb 21, 2011
sockmark %x $$1|msg $2

Forgot the space before and after the |

I knew there were more HTTP error codes but never bothered to look them up. Now I can do it the lazy way :P

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.