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
db311894
Commit
db311894
authored
Dec 15, 2000
by
Evan Simpson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't try to fix user HTML, and set content-length along with the body.
parent
2e2ab5d4
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
17 deletions
+21
-17
lib/python/ZPublisher/HTTPResponse.py
lib/python/ZPublisher/HTTPResponse.py
+21
-17
No files found.
lib/python/ZPublisher/HTTPResponse.py
View file @
db311894
...
@@ -84,8 +84,8 @@
...
@@ -84,8 +84,8 @@
##############################################################################
##############################################################################
'''CGI Response Output formatter
'''CGI Response Output formatter
$Id: HTTPResponse.py,v 1.3
8 2000/12/15 15:35:17 bri
an Exp $'''
$Id: HTTPResponse.py,v 1.3
9 2000/12/15 16:14:01 ev
an Exp $'''
__version__
=
'$Revision: 1.3
8
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.3
9
$'
[
11
:
-
2
]
import
string
,
types
,
sys
,
regex
,
re
import
string
,
types
,
sys
,
regex
,
re
from
string
import
find
,
rfind
,
lower
,
upper
,
strip
,
split
,
join
,
translate
from
string
import
find
,
rfind
,
lower
,
upper
,
strip
,
split
,
join
,
translate
...
@@ -161,7 +161,7 @@ status_codes['redirect']=300
...
@@ -161,7 +161,7 @@ status_codes['redirect']=300
start_of_header_search
=
re
.
compile
(
'(<head[^>]*>)'
,
re
.
IGNORECASE
).
search
start_of_header_search
=
re
.
compile
(
'(<head[^>]*>)'
,
re
.
IGNORECASE
).
search
end_of_header_search
=
regex
.
compile
(
'</head>'
,
regex
.
casefold
).
search
#
end_of_header_search=regex.compile('</head>',regex.casefold).search
accumulate_header
=
{
'set-cookie'
:
1
}.
has_key
accumulate_header
=
{
'set-cookie'
:
1
}.
has_key
...
@@ -315,6 +315,7 @@ class HTTPResponse(BaseResponse):
...
@@ -315,6 +315,7 @@ class HTTPResponse(BaseResponse):
self
.
body
=
self
.
_error_html
(
str
(
title
),
str
(
body
))
self
.
body
=
self
.
_error_html
(
str
(
title
),
str
(
body
))
else
:
else
:
self
.
body
=
str
(
body
)
self
.
body
=
str
(
body
)
self
.
setHeader
(
'content-length'
,
len
(
self
.
body
))
self
.
insertBase
()
self
.
insertBase
()
return
self
return
self
...
@@ -694,20 +695,23 @@ class HTTPResponse(BaseResponse):
...
@@ -694,20 +695,23 @@ class HTTPResponse(BaseResponse):
else
:
else
:
c
=
'text/plain'
c
=
'text/plain'
self
.
setHeader
(
'content-type'
,
c
)
self
.
setHeader
(
'content-type'
,
c
)
else
:
isHTML
=
split
(
headers
.
get
(
'content-type'
,
''
),
# Don't try to fix user HTML!
';'
)[
0
]
==
'text/html'
if
isHTML
and
end_of_header_search
(
self
.
body
)
<
0
:
#else:
lhtml
=
html_search
(
body
)
# isHTML = split(headers.get('content-type', ''),
if
lhtml
>=
0
:
# ';')[0] == 'text/html'
lhtml
=
lhtml
+
6
#if isHTML and end_of_header_search(self.body) < 0:
body
=
'%s<head></head>
\
n
%s'
%
(
body
[:
lhtml
],
body
[
lhtml
:])
# lhtml=html_search(body)
elif
contHTML
:
# if lhtml >= 0:
body
=
'<html><head></head>
\
n
'
+
body
# lhtml=lhtml+6
else
:
# body='%s<head></head>\n%s' % (body[:lhtml],body[lhtml:])
body
=
'<html><head></head>
\
n
'
+
body
+
'
\
n
</html>
\
n
'
# elif contHTML:
self
.
setBody
(
body
)
# body='<html><head></head>\n' + body
body
=
self
.
body
# else:
# body='<html><head></head>\n' + body + '\n</html>\n'
# self.setBody(body)
# body=self.body
if
not
headers
.
has_key
(
'content-length'
)
and
\
if
not
headers
.
has_key
(
'content-length'
)
and
\
not
headers
.
has_key
(
'transfer-encoding'
):
not
headers
.
has_key
(
'transfer-encoding'
):
...
...
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