Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
20d114ca
Commit
20d114ca
authored
Apr 01, 2009
by
Senthil Kumaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for issue5040. Adding test for Content-Length
parent
2ecd3c36
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
1 deletion
+29
-1
Lib/SimpleXMLRPCServer.py
Lib/SimpleXMLRPCServer.py
+1
-1
Lib/test/test_xmlrpc.py
Lib/test/test_xmlrpc.py
+28
-0
No files found.
Lib/SimpleXMLRPCServer.py
View file @
20d114ca
...
...
@@ -580,7 +580,7 @@ class CGIXMLRPCRequestHandler(SimpleXMLRPCDispatcher):
'explain'
:
explain
}
print
'Status: %d %s'
%
(
code
,
message
)
print
'Content-Type:
text/html'
print
'Content-Type:
%s'
%
BaseHTTPServer
.
DEFAULT_ERROR_CONTENT_TYPE
print
'Content-Length: %d'
%
len
(
response
)
print
sys
.
stdout
.
write
(
response
)
...
...
Lib/test/test_xmlrpc.py
View file @
20d114ca
...
...
@@ -11,6 +11,7 @@ import httplib
import
socket
import
StringIO
import
os
import
re
from
test
import
test_support
try
:
...
...
@@ -385,6 +386,21 @@ class SimpleServerTestCase(unittest.TestCase):
# protocol error; provide additional information in test output
self
.
fail
(
"%s
\
n
%s"
%
(
e
,
getattr
(
e
,
"headers"
,
""
)))
def
test_nonascii
(
self
):
start_string
=
'P
\
N{LATIN SMALL LETTER Y WITH CIRCUMFLEX}
t'
end_string
=
'h
\
N{LATIN SMALL LETTER O WITH HORN}
n'
try
:
p
=
xmlrpclib
.
ServerProxy
(
URL
)
self
.
assertEqual
(
p
.
add
(
start_string
,
end_string
),
start_string
+
end_string
)
except
(
xmlrpclib
.
ProtocolError
,
socket
.
error
)
as
e
:
# ignore failures due to non-blocking socket unavailable errors.
if
not
is_unavailable_exception
(
e
):
# protocol error; provide additional information in test output
self
.
fail
(
"%s
\
n
%s"
%
(
e
,
getattr
(
e
,
"headers"
,
""
)))
# [ch] The test 404 is causing lots of false alarms.
def
XXXtest_404
(
self
):
# send POST with httplib, it should return 404 header and
...
...
@@ -646,6 +662,18 @@ class CGIHandlerTestCase(unittest.TestCase):
# start with 44th char so as not to get http header, we just need only xml
self
.
assertRaises
(
xmlrpclib
.
Fault
,
xmlrpclib
.
loads
,
handle
[
44
:])
# Also test the content-length returned by handle_request
# Using the same test method inorder to avoid all the datapassing
# boilerplate code.
# Test for bug: http://bugs.python.org/issue5040
content
=
handle
[
handle
.
find
(
"<?xml"
):]
self
.
assertEquals
(
int
(
re
.
search
(
'Content-Length: (
\
d+)
'
, handle).group(1)),
len(content))
os.remove("xmldata.txt")
os.remove(test_support.TESTFN)
...
...
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