Roxen.git/
server/
etc/
modules/
Variable.pmod/
module.pmod
Branch:
Tag:
Non-build tags
All tags
No tags
2008-12-11
2008-12-11 11:00:06 by Jonas Wallden <jonasw@roxen.com>
77bdafc82c64d1f4a5b7de22a284d69fbbb392e4 (
38
lines) (+
25
/-
13
)
[
Show
|
Annotate
]
Branch:
5.2
Fix IPv6 bugs.
Rev: server/etc/modules/Variable.pmod/module.pmod:1.111
1:
-
// $Id: module.pmod,v 1.
110
2008/
09
/
25
22
:
51
:
37
mast
Exp $
+
// $Id: module.pmod,v 1.
111
2008/
12
/
11
11
:
00
:
06
jonasw
Exp $
#include <module.h> #include <roxen.h>
1883:
if( strlen( va[v+"path"] ) && va[v+"path"][-1] != '/' ) va[v+"path"]+="/";
-
return (string)Standards.URI(va[v+"prot"]+"://"
+va[v+"
host
"]
+
+
// Handle IPv6 addresses
+
string host = va[v + "host"];
+
if (has_value(host, ":") && !has_prefix(host, "["))
+
host = "[" + host + "]";
+
+
return (string)Standards.URI(va[v+"prot"]+"://"
+
host
+
(va[v+"port"] && sizeof (va[v+"port"]) ? ":"+ va[v+"port"] : "") +"/"+va[v+"path"]+"#" // all options below this point
2007:
protocol[..strlen(protocol)-2])+"\n"; #endif int pno;
-
if(
sscanf( host, "%s:%d", host,
pno
)
=
= 2)
-
if
(
roxenp()->protocols[
lower_case(
protocol
)
]
-
&&
(
pno
==
roxenp(
)->
protocols[ lower
_
case(
protocol
)
]->default
_
port
))
-
warning
+=
sprintf(LOCALE(341,"Removed
the
default
port
number "
-
"
(
%d)
from
%s"),
pno
,port
)
+"\n";
-
else
-
host
=
host+
":"
+pno
;
-
-
+
int
default_
pno =
+
(roxenp()->protocols[lower_case(protocol)]
||
(
[
])
)->
default
_
port;
+
if
(has
_
value(host,
"["
))
{
+
//
IPv6
address
+
Standards.URI
uri
= Standards.URI(
port
);
+
pno
=
uri->port;
+
port
=
(string)
uri;
+
}
else
{
+
if
(sscanf(host,
"%s:%d",
host,
pno)
==
2)
+
if
(
pno
!=
default_
pno)
+
host
=
host
+
":"
+ pno
;
port = protocol+"://"+host+path;
-
+
}
+
if (default_pno && (pno == default_pno))
+
warning += sprintf(LOCALE(341, "Removed the default port number "
+
"(%d) from %s"), pno, port) + "\n";
if( !roxenp()->protocols[ protocol ] ) warning += sprintf(LOCALE(342,"Warning: The protocol %s is not known "