Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
c5e79b5d
Commit
c5e79b5d
authored
Mar 18, 2011
by
Matthew Wilkes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Detect IPv6 hosts and use the appropriate address family.
parent
847f1c77
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
2 deletions
+26
-2
src/ZServer/medusa/http_server.py
src/ZServer/medusa/http_server.py
+10
-2
src/ZServer/tests/test_config.py
src/ZServer/tests/test_config.py
+16
-0
No files found.
src/ZServer/medusa/http_server.py
View file @
c5e79b5d
...
...
@@ -542,7 +542,12 @@ class http_server (asyncore.dispatcher):
self
.
ip
=
ip
self
.
port
=
port
asyncore
.
dispatcher
.
__init__
(
self
)
self
.
create_socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
if
':'
in
ip
:
socket_type
=
socket
.
AF_INET6
else
:
socket_type
=
socket
.
AF_INET
self
.
create_socket
(
socket_type
,
socket
.
SOCK_STREAM
)
self
.
handlers
=
[]
...
...
@@ -555,7 +560,10 @@ class http_server (asyncore.dispatcher):
# lower this to 5 if your OS complains
self
.
listen
(
1024
)
host
,
port
=
self
.
socket
.
getsockname
()
name
=
self
.
socket
.
getsockname
()
host
=
name
[
0
]
port
=
name
[
1
]
if
not
ip
:
self
.
log_info
(
'Computing default hostname'
,
'warning'
)
try
:
...
...
src/ZServer/tests/test_config.py
View file @
c5e79b5d
...
...
@@ -134,6 +134,22 @@ class ZServerConfigurationTestCase(BaseTest, WarningInterceptor):
self
.
assertEqual
(
server
.
port
,
9381
)
server
.
close
()
def
test_http_over_ipv6
(
self
):
factory
=
self
.
load_factory
(
"""
\
<http-server>
address [::1]:81
</http-server>
"""
)
self
.
assert_
(
isinstance
(
factory
,
ZServer
.
datatypes
.
HTTPServerFactory
))
self
.
assertEqual
(
factory
.
host
,
"::1"
)
self
.
assertEqual
(
factory
.
port
,
81
)
self
.
check_prepare
(
factory
)
server
=
factory
.
create
()
self
.
assertEqual
(
server
.
ip
,
'::1'
)
self
.
assertEqual
(
server
.
port
,
9381
)
server
.
close
()
def
test_http_factory_defaulthost
(
self
):
factory
=
self
.
load_factory
(
"""
\
<http-server>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment