html - Why is this document rendered as XML not HTML5? -
why second document below renedered xml not html? document.constructor
becomes xmldocument
.
edit web server replies application/xhtml+xml; charset=utf-8
when issue request browser (instead of curl
). noticed, when sniffing wireshark. perhaps need not have posted question then, since seems have configured web server incorrectly.
edit 2: lift-web issue (the web framework use). see reply below.
(this breaks google's svg web me. svg web works fine, in case, html not xml. , have no idea how make web browser consider document being html not xml -- think have specified html not xml.)
the first document below rendered html though. cannot life of me find relevant difference in http headers or <meta>
tags of first , second documents!?
(i've diffed them; there're uninteresting headers differ.)
in particular, both documents specify content-type: text/html; charset=utf-8
, both in http headers , <meta>
tags.
(does browser check other stuff, in addition http headers , tags , perhaps file suffix, derive content type?)
when debug javascript code:
document.constructor === xmldocument
true first document,
document.constructor === htmldocument
true second.
browser: google chrome 9.0.597.83 beta.
here follows first document , http headers, seen curl
: (this results in html)
$ curl -v -v http://localhost/foo/content-type-html-test.html | head -n10 * connect() localhost port 80 (#0) * trying 127.0.0.1... connected * connected localhost (127.0.0.1) port 80 (#0) > /foo/content-type-html-test.html http/1.1 > ... < http/1.1 200 ok < date: sun, 06 mar 2011 09:06:42 gmt < server: apache/2.2.14 (ubuntu) < last-modified: sun, 06 mar 2011 08:58:30 gmt < etag: "77402b-3bc4-49dcc95441980" < accept-ranges: bytes < content-length: 15300 < content-type: text/html; charset=utf-8 < ...curl shows download progress... * closing connection #0 <!doctype html> <html xmlns:lift="http://liftweb.net/" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=utf-8" http-equiv="content-type" /> <meta content="" name="description" /> <meta content="" name="keywords" /> <title>foo</title> <!-- svg.js must first script on page. --> <script src="./content-type-html-test_files/svg.js" type="text/javascript" data-path="/classpath/js" ></script> <!--<script data-path="/classpath/js" type="text/javascript" src="/classpath/js/svg.js"></script> --> <script src="./content-type-html-test_files/jquery-1.4.2.js" type="text/javascript" ></script>
the second: (results in xml)
$ curl -v -v http://localhost:8080/0/about.html | head -n10 * connect() localhost port 8080 (#0) * trying 127.0.0.1... connected * connected localhost (127.0.0.1) port 8080 (#0) > /0/about.html http/1.1 > ... < http/1.1 200 ok < expires: sun, 6 mar 2011 09:07:35 utc < set-cookie: jsessionid=1p9o4y4cv2d531as8s5xrdysch;path=/ < content-length: 11085 < cache-control: no-cache; private; no-store < content-type: text/html; charset=utf-8 < pragma: no-cache < date: sun, 6 mar 2011 09:07:35 utc < x-lift-version: 2.2 < server: jetty(6.1.25) < ...curl shows download progress... * closing connection #0 <!doctype html> <html xmlns:lift="http://liftweb.net/" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=utf-8" http-equiv="content-type" /> <meta content="" name="description" /> <meta content="" name="keywords" /> <title>foo</title> <!-- svg.js must first script on page. --> <script src="/classpath/js/svg.js" type="text/javascript" data-path="/classpath/js"></script> <!--<script data-path="/classpath/js" type="text/javascript" src="/classpath/js/svg.js"></script> -->
i read question morning , couldn't see problem was, i've seen edit think know is. typical request looks in firefox (using livehttpheaders):
get / http/1.1 host: stackoverflow.com user-agent: mozilla/5.0 (x11; u; linux x86_64; en-gb; rv:1.9.2.14) gecko/20110301 fedora/3.6.14-1.fc14 firefox/3.6.14 accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 accept-language: en-gb,en-us;q=0.7,en;q=0.3 accept-encoding: gzip,deflate accept-charset: iso-8859-1,utf-8;q=0.7,*;q=0.7 keep-alive: 115 connection: keep-alive
note line accept:
. suspect server sending text/html
curl because it's not explicitly declaring can support application/xhtml+xml
. since firefox (and presumably other browsers not ie) declare support it, server sends content type.
note reasonable thing web server do, not configuration error, suggest solution configure jetty send text/html
no matter accept:
header on request says.
Comments
Post a Comment