forked from pool/perl-RPC-XML
This commit is contained in:
75
RPC-XML-0.53-ext-daemon-and-header-cb.dif
Normal file
75
RPC-XML-0.53-ext-daemon-and-header-cb.dif
Normal file
@@ -0,0 +1,75 @@
|
||||
--- lib/RPC/XML/Server.pm
|
||||
+++ lib/RPC/XML/Server.pm 2003/12/03 17:53:25
|
||||
@@ -124,6 +124,11 @@
|
||||
$self->{__host} = $args{host} || '';
|
||||
$self->{__port} = $args{port} || '';
|
||||
delete @args{qw(host port)};
|
||||
+ } elsif( ref($args{http_daemon}) ) {
|
||||
+ $self->{__daemon} = $args{http_daemon};
|
||||
+ $self->{__http_header_parsing_cb} = $args{http_header_parsing_cb};
|
||||
+ delete $args{http_daemon};
|
||||
+ delete $args{http_header_parsing_cb};
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -142,9 +147,10 @@
|
||||
$self->{__host} = $URI->host;
|
||||
$self->{__port} = $URI->port;
|
||||
$self->{__daemon} = $http;
|
||||
+ $self->{__http_header_parsing_cb} = $args{http_header_parsing_cb};
|
||||
|
||||
# Remove those we've processed
|
||||
- delete @args{qw(host port queue)};
|
||||
+ delete @args{qw(host port queue http_header_parsing_cb)};
|
||||
}
|
||||
$resp = HTTP::Response->new();
|
||||
return "${class}::new: Unable to create HTTP::Response object"
|
||||
@@ -512,6 +518,23 @@
|
||||
specific directory in which to open those files. If this is not given, then
|
||||
the C<tmpdir> method from the B<File::Spec> package is used, instead.
|
||||
|
||||
+=item daemon
|
||||
+
|
||||
+you can provide a daemon object here, so RPC::XML::Server will not use
|
||||
+it's own HTTP::Daemon but your provided daemon object.
|
||||
+This parameter is optional.
|
||||
+
|
||||
+=item http_header_parsing_cb
|
||||
+
|
||||
+must be a code reference which will be called before anything else happens
|
||||
+to the HTTP data stream. It can be used to parse the HTTP header for HTTP
|
||||
+authentication checks and stuff like that.
|
||||
+This callback function will get the request object (HTTP::Request)
|
||||
+and the connection object (HTTP::Daemon::Clientconn) as parameters.
|
||||
+If the callback function does not return a true value, no further processing
|
||||
+of the request will be done.
|
||||
+This parameter is optional.
|
||||
+
|
||||
=back
|
||||
|
||||
Any other keys in the options hash not explicitly used by the constructor are
|
||||
@@ -1053,7 +1076,6 @@
|
||||
|
||||
=cut
|
||||
|
||||
-__END__
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
@@ -1341,6 +1363,11 @@
|
||||
|
||||
while ($req = $conn->get_request('headers only'))
|
||||
{
|
||||
+ if( ref($self->{__http_header_parsing_cb}) eq 'CODE' ) {
|
||||
+ # we terminate connection unless header parsing
|
||||
+ # returns a true value
|
||||
+ next unless( $self->{__http_header_parsing_cb}->( $req, $conn ) );
|
||||
+ }
|
||||
if ($req->method eq 'HEAD')
|
||||
{
|
||||
# The HEAD method will be answered with our return headers,
|
||||
@@ -2025,3 +2052,4 @@
|
||||
}
|
||||
return $old_timeout;
|
||||
}
|
||||
+__END__
|
Reference in New Issue
Block a user