Thread WebDAV Testscript (28 answers)
Opened by bianca at 2014-09-22 16:15

GwenDragon
 2014-09-22 17:08
#177458 #177458
User since
2005-01-17
14741 articles
Admin1
[Homepage]
user image
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/perl

use strict;
use warnings;

use 5.010;
use LWP::UserAgent;
use HTTP::Request;

sub has_dav {
    my $uri     = shift;
    my %options = @_;

    my $ua       = LWP::UserAgent->new;
    my $request  = HTTP::Request->new( OPTIONS => $uri );
    my $response = $ua->request($request);
    say STDERR $request->as_string if $options{DEBUG};
    say STDERR $response->as_string if $options{DEBUG};

    return $response->as_string =~ /DAV/i;
}

$| = 1;
say q(Hat DAV!
) if has_dav('http://testserver/dav/');

# und mit DEBUG
say q(---------------------------------
DEBUGMODE
Hat DAV!
---------------------------------
) if has_dav( 'http://testserver/dav/', DEBUG => 1 );



Hat DAV!

OPTIONS http://testserver/dav/
User-Agent: libwww-perl/6.07


HTTP/1.1 200 OK
Cache-Control: max-age=604800
Connection: close
Date: Mon, 22 Sep 2014 15:19:32 GMT
Server: Apache/2.2.25 (Win32) DAV/2 mod_ssl/2.2.25 OpenSSL/0.9.8y PHP/5.4.32 mod_apreq2-20090110/2.8.0 mod_perl/2.0.8 Perl/v5.14.4
Allow: OPTIONS,GET,HEAD,POST,DELETE,TRACE,PROPFIND,PROPPATCH,COPY,MOVE,LOCK,UNLOCK
Content-Length: 0
Content-Type: httpd/unix-directory
Expires: Mon, 29 Sep 2014 15:19:32 GMT
Client-Date: Mon, 22 Sep 2014 15:19:32 GMT
Client-Peer: 192.168.138.76:80
Client-Response-Num: 1
DAV: 1,2
MS-Author-Via: DAV


---------------------------------
DEBUGMODE
Hat DAV!
---------------------------------


Editiert von GwenDragon: richtigen Code + Ausgabe
Last edited: 2014-09-22 17:20:10 +0200 (CEST)

View full thread WebDAV Testscript