Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void traiterRequete(BufferedReader br, DataOutputStream dos)
- throws IOException {
- int position = 0;
- String nomFichier;
- String ligne = lireLigne("", br);
- if (ligne.startsWith("GET")) {
- try {
- position = ligne.indexOf("/");
- nomFichier = ligne.substring(position,ligne.indexOf("", position));
- if("text/html".equals(contentType(nomFichier))){
- contentTypeLine=contentType(nomFichier);
- retourFichier(nomFichier, dos);
- while(ligne!=null || ligne!="\n\r"){
- ligne = lireLigne("", br);
- }
- }
- else{
- //on ne sait pas
- }
- } catch (IndexOutOfBoundsException ex) {
- System.out.println(ex);
- }
- }
- else if (ligne.startsWith("POST")) {
- try{
- position = ligne.indexOf("/");
- nomFichier = ligne.substring(position,ligne.indexOf("", position));
- if("text/html".equals(contentType(nomFichier))){
- contentTypeLine=contentType(nomFichier);
- retourFichier(nomFichier, dos);
- while(ligne!=null || ligne!="\n\r"){
- ligne = lireLigne("", br);
- }
- }
- else{
- retourCGIPOST(nomFichier, br, dos);
- }
- }
- catch (IndexOutOfBoundsException ex) {
- System.out.println(ex);
- }
- }
- else{
- ligne = lireLigne("", br);
- }
- /*
- * Cette methode lit des lignes sur br (utiliser LireLigne) et recherche une ligne commencant par GET ou par POST.
- *
- * Si la ligne commence par GET: ok
- * ­ on extrait le nom de fichier demande dans la ligne et on appelle la methode retourFichier. ok( a tester si le nomFichier est bon)
- * ­ Si le suffixe du nom de fichier est .htm ou .html (utiliser la methode contentType) ok
- * ­ on lit ensuite toutes les lignes qui suivent jusqu'a en trouver une vide, nulle ou contenant juste "\n\r" ok
- *
- * Si la ligne commence par POST
- * ­ on extrait le nom de fichier demande dans la ligne et on appelle la methode retourFichier.
- * ­ Si le suffixe du nom de fichier est .htm ou .html, on fait la meme chose que ci dessus pour GET
- * ­ Si le suffixe est autre, on appelle la methode retourCGIPOST
- */
- } // traiterRequete
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement