Page 1 sur 2

En-têtes HTTP érronées

Publié : 29 oct. 2005, 02:46
par Bacchus
Pourquoi est-ce que mes pages coder en XHTML et ayant comme MIME application/xhtml+xml, sont traité come du text/html quand même?

Et je n'utilise pas le prolog xml à cause des probs du box-model.

Publié : 29 oct. 2005, 10:05
par SB
J'oserais invoquer sans certitude le comportement de ton serveur qui envoie tes pages au format text/html sans tenir compte des balises meta.
Essaie un code php genre

Code : Tout sélectionner

<?php
if( stristr($HTTP_SERVER_VARS["HTTP_ACCEPT"], "application/xhtml+xml") || empty($HTTP_SERVER_VARS["HTTP_ACCEPT"])) 
	{
	header("Content-type: application/xhtml+xml");
	echo "<?xml version='1.0' encoding='iso-8859-1'?>\n";
	echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n";
	echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"fr\">\n";
	}
else 
	{
	header("Content-type: text/html; charset=iso-8859-1");
	echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n";
	echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"fr\">\n";
	}
?>
à la place de

Code : Tout sélectionner

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
et supprime la balise <meta>

Re: En-têtes HTTP érronées

Publié : 29 oct. 2005, 11:18
par calimo
Bacchus a écrit :Pourquoi est-ce que mes pages coder en XHTML et ayant comme MIME application/xhtml+xml, sont traité come du text/html quand même?
Parce qu'elles ne sont pas envoyées en application/xhtml+xml ?
Moi dans les entêtes HTTP je vois

Code : Tout sélectionner

Content-Type: text/html; charset=iso-8859-1 
:roll:
Bacchus a écrit :Et je n'utilise pas le prolog xml à cause des probs du box-model.
Eh, en XML il est obligatoire ! :lol:

http://www.hixie.ch/advocacy/xhtml.fr/ :wink:

Publié : 29 oct. 2005, 21:11
par Bacchus
Je vais tester ta méthode SB.

Calimo, je sais ce que tu vois, c'est pour ça que je dis qu'elle sont érronés regarde le code source:

http://users.rockweb.org/Isolder/index.php

ailleur j'ai vu que le prolog xml est pas obligatoire:

http://www.geckozone.org/forum/viewtopi ... 556#178556

Publié : 29 oct. 2005, 21:35
par calimo
Bacchus a écrit :Calimo, je sais ce que tu vois, c'est pour ça que je dis qu'elle sont érronés regarde le code source:

http://users.rockweb.org/Isolder/index.php
Ben… ce n'est pas juste en le voulant (même très fort) que ça va passer en application/xhtml+xml tout seul. Il faut envoyer les entêtes, qui ne font pas partie de la page elle-même.

Avant de recevoir la page, un dialogue s'installe entre le navigateur et le serveur. Le navigateur demande la page en donnant quelques infos sur qui il est, ce qu'il préfère, etc., puis le serveur répond en donnant d'abord les infos sur la page (taille, type de contenu, date de modification etc.). Ils échangent des entêtes HTTP, dont une "Content-type" qui, dans ton cas, est text/html.
Et seulement ensuite la page est envoyée.

Donc c'est le serveur qu'il faut régler. Ça se passe en amont de la page. SB te donne une possibilité.
Juste un petit détail (un gros détail en fait. Non, ce n'est pas un détail du tout !) : un doctype XHTML 1.1 n'est pas du tout adapté.
  1. Bacchus fais du XHTML 1.0 Transitionnal, donc il n'y a aucune raison de penser que subitement ses pages se transformeront en XHTML 1.1
  2. Dans else {} tu envoies tu XHTML 1.1 en text/html ce qui est strictement interdit :evil:
Bref, il faudra adapter le code.

Si vous voulez mon avis, il n'y a rien de pire que d'avoir deux versions, une HTML et une XHTML, c'est l'assurance d'avoir des ennuis et des comportements imprévisibles et différents. :roll: :?
(voir http://www.hixie.ch/advocacy/xhtml.fr/)
Bacchus a écrit :ailleur j'ai vu que le prolog xml est pas obligatoire:

http://www.geckozone.org/forum/viewtopi ... 556#178556
En HTML effectivement ce n'est pas obligatoire. Mais là si tu veux passer en XML tu n'auras plus le choix :wink:

Publié : 04 nov. 2005, 00:17
par Bacchus
Bon j'ai finalement tester et ça marche pas du tout, ou alors c'est ma faute vu que j'ai modifier le code.

J'ai mis ceci:

Code : Tout sélectionner

<?php
if( stristr($HTTP_SERVER_VARS["HTTP_ACCEPT"], "application/xhtml+xml") || empty($HTTP_SERVER_VARS["HTTP_ACCEPT"]))
   {
   header("Content-type: application/xhtml+xml");
   echo "<?xml version='1.0' encoding='iso-8859-1'?>\n";
   echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml1-transitional.dtd\">\n";
   echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"fr\" xml:lang=\"fr\">\n";
   }
else
   {
   header("Content-type: text/html; charset=iso-8859-1");
   echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n";
   echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"fr\">\n";
   }
?>
Et voila le résultat avec firefox, avec IE c'est nickel alors je crois que je vais laisser tomber FF pour IE. (humour)

Je crois que ces cette ligne qui foire tout:

Code : Tout sélectionner

echo "<?xml version='1.0' encoding='iso-8859-1'?>\n";
Car mon éditeur de texte (Pspad) crois que c'est le ?> fermant de l'encodage qui est la fin du code php (<?php).

D'autre idée, j'ai été voir mon hébergeur et je n'ai recu encore aucune réponse.

Publié : 04 nov. 2005, 08:13
par SB
Le résultat que tu veux nous montrer avec "Et voila le résultat avec firefox" c'est la bonne page ? Parce qu'il n'y a aucune différence entre IE et Fx au niveau du code donc j'ai l'impression que le code php n'y est pas.
Pour faire simple donne nous tout ton code depuis le début de la page jusqu'à la balise </head>

Publié : 04 nov. 2005, 09:42
par Bacchus_non_connecter
Décalage horaire oblige, j'ai remis la page normalement pour la nuit, il est présentement 3:40AM au Québec. (baille)

Bref, firefox me donnait une erreur XML, comme quoi il n'y avait pas de contenue. Je remettrai le bug en ligne demain matin.

Publié : 04 nov. 2005, 19:05
par Bacchus
Me revoila, l'erreur en question.

J'ai penser à mettre <script language="php">à la place de <?php, c'est une bonne idée?

Publié : 04 nov. 2005, 19:19
par calimo
Tu as deux éléments html, mais un seul est refermé.

N'oublie pas que tu es en XML, tu n'as plus le droit à l'erreur (de syntaxe). Le parseur s'arrête si le XML est mal formé (= si un élément n'est pas fermé, si une entité n'est pas définie, si un guillemet manque, etc.). C'est exactement ce qui est dit sur la page http://www.hixie.ch/advocacy/xhtml.fr/ que je citais plus haut ;-)

PS : tu envoies un doctype XHTML 1.1 à IE. Tu dois aussi lui mettre un doctype XHTMl 1.0 transitionnal :wink:

PPS : tu peux essayer de mettre un <script>, tu verra tout de suite le résultat. N'oublie pas que le php est interprété sur le serveur :wink:

Publié : 04 nov. 2005, 20:01
par Bacchus
Ouais, ça marche en apparence et l'entête HTTP est correcte(vérifié avec webdev)

Tu avais raison, les deux

Code : Tout sélectionner

echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"fr\" xml:lang=\"fr\">\n";
causaient problème.

Donc code à mettre:

Code : Tout sélectionner

<?php
if( stristr($HTTP_SERVER_VARS["HTTP_ACCEPT"], "application/xhtml+xml") || empty($HTTP_SERVER_VARS["HTTP_ACCEPT"]))
   {
   header("Content-type: application/xhtml+xml");
   echo "<?xml version='1.0' encoding='iso-8859-1'?>\n";
   echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml1-transitional.dtd\">\n";
   //echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"fr\" xml:lang=\"fr\">\n";
   }
else
   {
   header("Content-type: text/html; charset=iso-8859-1");
   echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n";
   //echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"fr\" xml:lang=\"fr\">\n";
   }
?>
EDIT: Erreur monumentale!!! :cry: :cry:

Sous firefox le design foire grave et ma bannière google à droite à disparus. Sous IE c'est nickel, vraiment firefox est nul (humour).

Je vais remettre l'ancienne version et botté les fesses de mon hébergeur. :x

Publié : 04 nov. 2005, 20:39
par SB
Ben maintenant y a 2 doctypes...
Je te l'ai déjà dit : donne nous tout ton code depuis le début jusqu'à </head>.

Publié : 04 nov. 2005, 20:52
par Bacchus_non_connecter
Sans le code php:

Code : Tout sélectionner

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<link rel="icon" type="images/ico" href="images/anarchy.ico" />
<link rel="shortcut icon" href="images/anarchy.ico" />
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=iso-8859-1" />
<meta http-equiv="Content-Language" content="fr" />
<meta name="generator" content="PSPad editor, www.pspad.com" />
<meta name="dc.title" content="My World!! -- Un site pour tous!" />
<meta name="description" lang="fr" xml:lang="fr" content="Un site web pour ce détendre et pour apprendre un truc ou deux." />
<meta name="keywords" lang="fr" xml:lang="fr" content="Bacchus, Psyco, Thug, Psyco Thug, psyco_thug, sci-fi, science-fiction, star wars, stargate, pc, news, s&eacute;curit&eacute;, info, po&eacute;sie, darksoul, dark." />
<meta name="author" content="Bacchus" />
<meta name="identifier-URL" content="http://users.rockweb.org/Isolder/index.php" />
<meta name="reply-to" content="pseudo@email.com" />
<meta name="copyright" content="Bacchus 2004-2005" />
<meta name="classification" content="Informatique, Site personnel, Soci&eacute;t&eacute;" />
<meta name="language" content="fr" />
<meta name="pays" content="CA" />
<meta name="distribution" content="global" />
<meta name="robots" content="index, follow" />
<meta name="revisit-after" content="15 days" />
<meta name="revised" content="Bacchus 2005/08/04" />
<link rel="stylesheet" type="text/css" href="styles/<?php echo (!$sitestyle)?'style':$sitestyle ?>.css" media="screen" title="Dark Style" />
<link rel="alternate stylesheet" type="text/css" href="styles/litestyle.css" media="screen" title="Lite Style" />
<link rel="alternate stylesheet" type="text/css" href="styles/naked.css" media="screen" title="Naked Style" />
<link rel="alternate stylesheet" type="text/css" href="styles/blood.css" media="screen" title="Blood Style" />
<link rel="alternate stylesheet" type="text/css" href="styles/dotparking.css" media="screen" title="DotParking" />
<title>My World!! -- Un site pour tous!</title>
<script type="text/javascript" src="scroll/ts_files/scroll.js"></script>
</head>
Et avec:

Code : Tout sélectionner

<?php
if( stristr($HTTP_SERVER_VARS["HTTP_ACCEPT"], "application/xhtml+xml") || empty($HTTP_SERVER_VARS["HTTP_ACCEPT"]))
   {
   header("Content-type: application/xhtml+xml");
   echo "<?xml version='1.0' encoding='iso-8859-1'?>\n";
   echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml1-transitional.dtd\">\n";
   //echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"fr\" xml:lang=\"fr\">\n";
   }
else
   {
   header("Content-type: text/html; charset=iso-8859-1");
   echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n";
   //echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"fr\" xml:lang=\"fr\">\n";
   }
?>

<!--DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"-->

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<link rel="icon" type="images/ico" href="images/anarchy.ico" />
<link rel="shortcut icon" href="images/anarchy.ico" />
<!--meta http-equiv="Content-Type" content="application/xhtml+xml; charset=iso-8859-1" /-->
<meta http-equiv="Content-Language" content="fr" />
<meta name="generator" content="PSPad editor, www.pspad.com" />
<meta name="dc.title" content="My World!! -- Un site pour tous!" />
<meta name="description" lang="fr" xml:lang="fr" content="Un site web pour ce détendre et pour apprendre un truc ou deux." />
<meta name="keywords" lang="fr" xml:lang="fr" content="Bacchus, Psyco, Thug, Psyco Thug, psyco_thug, sci-fi, science-fiction, star wars, stargate, pc, news, s&eacute;curit&eacute;, info, po&eacute;sie, darksoul, dark." />
<meta name="author" content="Bacchus" />
<meta name="identifier-URL" content="http://users.rockweb.org/Isolder/index.php" />
<meta name="reply-to" content="pseudo@email.com" />
<meta name="copyright" content="Bacchus 2004-2005" />
<meta name="classification" content="Informatique, Site personnel, Soci&eacute;t&eacute;" />
<meta name="language" content="fr" />
<meta name="pays" content="CA" />
<meta name="distribution" content="global" />
<meta name="robots" content="index, follow" />
<meta name="revisit-after" content="15 days" />
<meta name="revised" content="Bacchus 2005/08/04" />
<link rel="stylesheet" type="text/css" href="styles/<?php echo (!$sitestyle)?'style':$sitestyle ?>.css" media="screen" title="Dark Style" />
<link rel="alternate stylesheet" type="text/css" href="styles/litestyle.css" media="screen" title="Lite Style" />
<link rel="alternate stylesheet" type="text/css" href="styles/naked.css" media="screen" title="Naked Style" />
<link rel="alternate stylesheet" type="text/css" href="styles/blood.css" media="screen" title="Blood Style" />
<link rel="alternate stylesheet" type="text/css" href="styles/dotparking.css" media="screen" title="DotParking" />
<title>My World!! -- Un site pour tous!</title>
<script type="text/javascript" src="scroll/ts_files/scroll.js"></script>
</head>

Publié : 04 nov. 2005, 20:54
par calimo
Hum… les doctypes sont… comment dire … très personnels :lol:

Code : Tout sélectionner

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml1-transitional.dtd">
Un joli mélange de XHTML 1.1 et de 1.0Transitionnal :mrgreen:

Reprends le doctype officiel : http://www.w3.org/QA/2002/04/valid-dtd-list.html
Et les deux fois, surtout la deuxième (envoyée à IE) d'ailleurs :wink:
Bacchus a écrit :Sous firefox le design foire grave et ma bannière google à droite à disparus.
Hé, tu as lu cette page ? Ce n'est pas pour rien que je te la répète à longueur de sujet. Elle contient des informations importantes. Lis-là et seulement ensuite reviens ici. Parce que ça n'a rien d'étonnant. Tu en es au point 6 : «L’auteur accuse le XHTML.» :wink:

Lis cette page. Elle contient tout ce que tu dois savoir.

Publié : 04 nov. 2005, 21:29
par SB
Relis mon premier post. J'avais écris
à la place de
Essaie :

Code : Tout sélectionner

<?php
if( stristr($HTTP_SERVER_VARS["HTTP_ACCEPT"], "application/xhtml+xml") || empty($HTTP_SERVER_VARS["HTTP_ACCEPT"]))
   {
   header("Content-type: application/xhtml+xml");
   echo "<?xml version='1.0' encoding='iso-8859-15'?>\n";
   echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
   \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
   echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"fr\">\n";
   }
else
   {
   header("Content-type: text/html; charset=iso-8859-15");
   echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
   \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
  echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"fr\" xml:lang=\"fr\">\n";
   }
?>
<head>
<link rel="icon" type="images/ico" href="images/anarchy.ico" />
<link rel="shortcut icon" href="images/anarchy.ico" />
<meta name="generator" content="PSPad editor, www.pspad.com" />
<meta name="dc.title" content="My World!! -- Un site pour tous!" />
<meta name="description" content="Un site web pour ce détendre et pour apprendre un truc ou deux." />
<meta name="keywords" content="Bacchus, Psyco, Thug, Psyco Thug, psyco_thug, sci-fi, science-fiction, star wars, stargate, pc, news, s&eacute;curit&eacute;, info, po&eacute;sie, darksoul, dark." />
<meta name="author" content="Bacchus" />
<meta name="identifier-URL" content="http://users.rockweb.org/Isolder/index.php" />
<meta name="reply-to" content="pseudo@email.com" />
<meta name="copyright" content="Bacchus 2004-2005" />
<meta name="classification" content="Informatique, Site personnel, Soci&eacute;t&eacute;" />
<meta name="pays" content="CA" />
<meta name="distribution" content="global" />
<meta name="robots" content="index, follow" />
<meta name="revisit-after" content="15 days" />
<meta name="revised" content="Bacchus 2005/08/04" />
<link rel="stylesheet" type="text/css" href="styles/<?php echo (!$sitestyle)?'style':$sitestyle ?>.css" media="screen" title="Dark Style" />
<link rel="alternate stylesheet" type="text/css" href="styles/litestyle.css" media="screen" title="Lite Style" />
<link rel="alternate stylesheet" type="text/css" href="styles/naked.css" media="screen" title="Naked Style" />
<link rel="alternate stylesheet" type="text/css" href="styles/blood.css" media="screen" title="Blood Style" />
<link rel="alternate stylesheet" type="text/css" href="styles/dotparking.css" media="screen" title="DotParking" />
<title>My World!! -- Un site pour tous!</title>
<script type="text/javascript" src="scroll/ts_files/scroll.js"></script>
</head>
Sans oublier qu'avant le "<?php..." il ne doit rien y avoir, même pas un espace vide, sinon ça va capoter au niveau de la ligne "header...".