[PATCH] HTTP::Daemon defaults

[PATCH] HTTP::Daemon defaults

am 10.12.2004 19:15:35 von kees

--IiVenqGWf+H9Y6IX
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

I'd like to see this patch added so that HTTP::Daemon::SSL can more
cleanly overload the "url" function without having to totally reimplement
it.

Also, could HTTP::Daemon::SSL be made part of the libwww bundle?

Thanks!

--
Kees Cook
Open Source Development Lab
kees@osdl.org

--IiVenqGWf+H9Y6IX
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="daemon-defaults.patch"

diff -buNr libwww-perl-5.802/lib/HTTP/Daemon.pm libwww-perl-5.802-kees/lib/HTTP/Daemon.pm
--- libwww-perl-5.802/lib/HTTP/Daemon.pm 2004-04-09 13:21:43.000000000 -0700
+++ libwww-perl-5.802-kees/lib/HTTP/Daemon.pm 2004-12-10 10:13:30.000000000 -0800
@@ -37,10 +37,22 @@
}


+sub _default_port {
+ 443;
+}
+
+
+sub _default_scheme {
+ "https";
+}
+
+
+# Implemented with calls to "_default_port" and "_default_scheme" so that
+# HTTP::Daemon::SSL can overload them and still use this function.
sub url
{
my $self = shift;
- my $url = "http://";
+ my $url = $self->_default_scheme()."://";
my $addr = $self->sockaddr;
if (!$addr || $addr eq INADDR_ANY) {
require Sys::Hostname;
@@ -50,7 +62,7 @@
$url .= gethostbyaddr($addr, AF_INET) || inet_ntoa($addr);
}
my $port = $self->sockport;
- $url .= ":$port" if $port != 80;
+ $url .= ":$port" if $port != $self->_default_port();
$url .= "/";
$url;
}

--IiVenqGWf+H9Y6IX--

Re: [PATCH] HTTP::Daemon defaults

am 11.12.2004 15:15:38 von gisle

Kees Cook writes:

> I'd like to see this patch added so that HTTP::Daemon::SSL can more
> cleanly overload the "url" function without having to totally reimplement
> it.

Thanks. Applied.

But I made the defaults 80 and "http" :)

> Also, could HTTP::Daemon::SSL be made part of the libwww bundle?

I don't have a problem with that if its author wants the same.

Regards,
Gisle


> --- libwww-perl-5.802/lib/HTTP/Daemon.pm 2004-04-09 13:21:43.000000000 -0700
> +++ libwww-perl-5.802-kees/lib/HTTP/Daemon.pm 2004-12-10 10:13:30.000000000 -0800
> @@ -37,10 +37,22 @@
> }
>
>
> +sub _default_port {
> + 443;
> +}
> +
> +
> +sub _default_scheme {
> + "https";
> +}
> +
> +
> +# Implemented with calls to "_default_port" and "_default_scheme" so that
> +# HTTP::Daemon::SSL can overload them and still use this function.
> sub url
> {
> my $self = shift;
> - my $url = "http://";
> + my $url = $self->_default_scheme()."://";
> my $addr = $self->sockaddr;
> if (!$addr || $addr eq INADDR_ANY) {
> require Sys::Hostname;
> @@ -50,7 +62,7 @@
> $url .= gethostbyaddr($addr, AF_INET) || inet_ntoa($addr);
> }
> my $port = $self->sockport;
> - $url .= ":$port" if $port != 80;
> + $url .= ":$port" if $port != $self->_default_port();
> $url .= "/";
> $url;
> }