Firefox: all I get is XML page source code

G

Gnarlodious

Wit's end on this. I have a script outputting a stream with:
sys.stdout.buffer.write(("""\n<?xml version='1.0' encoding='utf-8'?>

The script works normally in 2 browsers, but in Firefox all I see is
source code.

Also, running the script in iPhone from my server shows the same
source code. Which is a little strange since iPhone and Safari both
use Webkit. This occurs also on my home dev server.

I attempted to validate the output but all I get is error:


Sorry, I am unable to validate this document because its content type
is text/plain, which is not currently supported by this service.
The Content-Type header is sent by your web server (or web browser if
you use the file upload interface) and depends on its configuration.
Commonly, web servers will have a mapping of filename extensions (such
as ".html") to MIME Content-Type values (such as text/html).
That you received this message can mean that your server is not
configured correctly, that your file does not have the correct
filename extension, or that you are attempting to validate a file type
that we do not support yet.


Is the output stream not recognized because of the
sys.stdout.buffer.write statement?

This is a Python3 script ending with .py. Server is Apache 2. Hope
someone can explain.

-- Gnarlie
 
D

Dennis Lee Bieber

Wit's end on this. I have a script outputting a stream with:
sys.stdout.buffer.write(("""\n<?xml version='1.0' encoding='utf-8'?>

The script works normally in 2 browsers, but in Firefox all I see is
source code.

Also, running the script in iPhone from my server shows the same
source code. Which is a little strange since iPhone and Safari both
use Webkit. This occurs also on my home dev server.

I attempted to validate the output but all I get is error:
<snip>

No headers?

Shouldn't there be something like:

"""
Content-Type: text/xml

<?xml...
"""

in the output?
 
G

Gnarlodious

Thanks for that, for some reason I assumed sys.stdout.buffer.write
sent the http header but I was wrong.

Even so, Firefox still refused to render prperly, but this works/:

content-type: application/xhtml+xml; charset=utf-8\n\n

-- Gnarlie
 
M

MRAB

Gnarlodious said:
Thanks for that, for some reason I assumed sys.stdout.buffer.write
sent the http header but I was wrong.

Even so, Firefox still refused to render prperly, but this works/:

content-type: application/xhtml+xml; charset=utf-8\n\n
Perhaps it's not so much that there's a problem with Firefox but that
the other browsers are guessing what the content type should be if it's
missing. (Refusing to guess is a Pythonic trait. :))
 
D

Dennis Lee Bieber

Thanks for that, for some reason I assumed sys.stdout.buffer.write
sent the http header but I was wrong.

Even so, Firefox still refused to render prperly, but this works/:

content-type: application/xhtml+xml; charset=utf-8\n\n

Sorry if I gave the impression that I'd specified a valid header...
One would, of course, have to find the list of recognized types.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top