Commit 131a4ee2 authored by Evan Simpson's avatar Evan Simpson

Don't try to fix user HTML.

parent 5eb1539a
...@@ -92,7 +92,7 @@ and logging duties. ...@@ -92,7 +92,7 @@ and logging duties.
import time, regex, string, sys, tempfile import time, regex, string, sys, tempfile
from cStringIO import StringIO from cStringIO import StringIO
import thread import thread
from ZPublisher.HTTPResponse import HTTPResponse, end_of_header_search from ZPublisher.HTTPResponse import HTTPResponse
from medusa.http_date import build_http_date from medusa.http_date import build_http_date
from PubCore.ZEvent import Wakeup from PubCore.ZEvent import Wakeup
from medusa.producers import hooked_producer from medusa.producers import hooked_producer
...@@ -140,21 +140,23 @@ class ZServerHTTPResponse(HTTPResponse): ...@@ -140,21 +140,23 @@ class ZServerHTTPResponse(HTTPResponse):
else: else:
c='text/plain' c='text/plain'
self.setHeader('content-type',c) self.setHeader('content-type',c)
else:
isHTML = string.split(headers.get('content-type', ''), # Don't try to fix user HTML
';')[0] == 'text/html'
#else:
if isHTML and end_of_header_search(self.body) < 0: # isHTML = string.split(headers.get('content-type', ''),
lhtml=html_search(body) # ';')[0] == 'text/html'
if lhtml >= 0: #if isHTML and end_of_header_search(self.body) < 0:
lhtml=lhtml+6 # lhtml=html_search(body)
body='%s<head></head>\n%s' % (body[:lhtml],body[lhtml:]) # if lhtml >= 0:
elif contHTML: # lhtml=lhtml+6
body='<html><head></head>\n' + body # body='%s<head></head>\n%s' % (body[:lhtml],body[lhtml:])
else: # elif contHTML:
body='<html><head></head>\n' + body + '\n</html>\n' # body='<html><head></head>\n' + body
self.setBody(body) # else:
body=self.body # body='<html><head></head>\n' + body + '\n</html>\n'
# self.setBody(body)
# body=self.body
# set 204 (no content) status if 200 and response is empty # set 204 (no content) status if 200 and response is empty
# and not streaming # and not streaming
......
...@@ -92,7 +92,7 @@ and logging duties. ...@@ -92,7 +92,7 @@ and logging duties.
import time, regex, string, sys, tempfile import time, regex, string, sys, tempfile
from cStringIO import StringIO from cStringIO import StringIO
import thread import thread
from ZPublisher.HTTPResponse import HTTPResponse, end_of_header_search from ZPublisher.HTTPResponse import HTTPResponse
from medusa.http_date import build_http_date from medusa.http_date import build_http_date
from PubCore.ZEvent import Wakeup from PubCore.ZEvent import Wakeup
from medusa.producers import hooked_producer from medusa.producers import hooked_producer
...@@ -140,21 +140,23 @@ class ZServerHTTPResponse(HTTPResponse): ...@@ -140,21 +140,23 @@ class ZServerHTTPResponse(HTTPResponse):
else: else:
c='text/plain' c='text/plain'
self.setHeader('content-type',c) self.setHeader('content-type',c)
else:
isHTML = string.split(headers.get('content-type', ''), # Don't try to fix user HTML
';')[0] == 'text/html'
#else:
if isHTML and end_of_header_search(self.body) < 0: # isHTML = string.split(headers.get('content-type', ''),
lhtml=html_search(body) # ';')[0] == 'text/html'
if lhtml >= 0: #if isHTML and end_of_header_search(self.body) < 0:
lhtml=lhtml+6 # lhtml=html_search(body)
body='%s<head></head>\n%s' % (body[:lhtml],body[lhtml:]) # if lhtml >= 0:
elif contHTML: # lhtml=lhtml+6
body='<html><head></head>\n' + body # body='%s<head></head>\n%s' % (body[:lhtml],body[lhtml:])
else: # elif contHTML:
body='<html><head></head>\n' + body + '\n</html>\n' # body='<html><head></head>\n' + body
self.setBody(body) # else:
body=self.body # body='<html><head></head>\n' + body + '\n</html>\n'
# self.setBody(body)
# body=self.body
# set 204 (no content) status if 200 and response is empty # set 204 (no content) status if 200 and response is empty
# and not streaming # and not streaming
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment