DisplayName
DisplayName

Reputation: 209

Browser just downloads page when I set the header to xml/text

I have a php file where everything works fine, but If I set the header to:

header("Content-type: xml/text");

Like it should be, my browser just tries to download it. It works with curl, but not Safari. It's weird because I have a lot of files that have that header on my server and they work, I even created a test php and set the header to that and it worked. How can I debug why that specfic page downloads when I set the header?

Upvotes: 1

Views: 44

Answers (1)

CodeBoy
CodeBoy

Reputation: 3300

Try

header("Content-type: text/xml");

text/xml is correct mime-type. Different user agents likely handle the invalid xml/text mime type differently, resulting in weirdness.

(More precisely, use text/xml if there is some intention that the XML could be readable by a human and use application/xml if not. Both these two are valid mime types for XML.)

Upvotes: 1

Related Questions