]> git.donarmstrong.com Git - infobot.git/commitdiff
HTTPDtype from #php
authortimriker <timriker@c11ca15a-4712-0410-83d8-924469b57eb5>
Tue, 11 Nov 2003 02:40:22 +0000 (02:40 +0000)
committertimriker <timriker@c11ca15a-4712-0410-83d8-924469b57eb5>
Tue, 11 Nov 2003 02:40:22 +0000 (02:40 +0000)
git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@873 c11ca15a-4712-0410-83d8-924469b57eb5

src/CommandStubs.pl
src/Modules/HTTPDtype.pl [new file with mode: 0644]
src/modules.pl

index c37729a42ca267363f62334da7a92af67c07aea3..bdcaf0b107ed940672bbf059d0aac74331d4cfd6 100644 (file)
@@ -248,6 +248,9 @@ sub parseCmdHook {
        'Forker' => 1) );
 &addCmdHook("extra", '(botmail|message)', ('CODEREF' => 'botmail::parse',
        'Identifier' => 'botmail', 'Cmdstats' => 'botmail') );
+&addCmdHook("extra", 'httpdtype', ('CODEREF' => 'HTTPDtype::HTTPDtype',
+       'Identifier' => 'httpdtype', 'Cmdstats' => 'httpdtype',
+       'Forker' => 1) );
 
 ###
 ### END OF ADDING HOOKS.
diff --git a/src/Modules/HTTPDtype.pl b/src/Modules/HTTPDtype.pl
new file mode 100644 (file)
index 0000000..3494846
--- /dev/null
@@ -0,0 +1,33 @@
+# HTTPDtype.pl: retrieves http server headers
+#       Author: Joey Smith <joey@php.net>
+#    Licensing: Artistic License
+#      Version: v0.1 (20031110)
+#
+use strict;
+
+package HTTPDtype;
+
+sub HTTPDtype {
+    my ($HOST) = @_;
+    my($line) = '';
+    my($code, $mess, %h);
+
+    $HOST = 'joeysmith.com' unless length($HOST) > 0;
+    return unless &::loadPerlModule("Net::HTTP::NB");
+    return unless &::loadPerlModule("IO::Select");
+
+        my $s = Net::HTTP::NB->new(Host => $HOST) || return;
+        $s->write_request(HEAD => "/");
+
+        my $sel = IO::Select->new($s);
+        $line = "Header timeout" unless $sel->can_read(10);
+        ($code, $mess, %h) = $s->read_response_headers;
+
+        $line = (length($h{Server}) > 0) ? $h{Server} :
+          "Couldn't fetch headers from $HOST";
+
+    &::pSReply($line||"Unknown Error Condition");
+
+}
+
+1;
index 3dbda5825fb3ca73d2f545fa3ee823ab5b7967d5..05d22f38133a01e442d7c6a96795486002914b41 100644 (file)
@@ -55,6 +55,7 @@ if ($@) {
        "zippy"         => "Zippy.pl",
        "zsi"           => "zsi.pl",
        "botmail"       => "botmail.pl",
+       "httpdtype"     => "HTTPDtype.pl",
 );
 ### THIS IS NOT LOADED ON RELOAD :(
 my @myModulesLoadNow;