Source Code Cross Referenced for RequeteHTTP.java in  » Web-Server » javahttpserver » httpserver » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Server » javahttpserver » httpserver 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * <p>
003:         * Title: RequeteHTTP
004:         * </p>
005:         * 
006:         * <p>
007:         * Description: Represente les Requetes HTTP.
008:         * </p>
009:         * 
010:         * <p>
011:         * Copyright: Copyright (c) 2005
012:         * </p>
013:         * 
014:         * <p>
015:         * Company:
016:         * </p>
017:         * 
018:         * @author Adlani Anouar - Detante Antoine - Klein Gregory - Pepin Pierre
019:         * @version 1.0
020:         */package httpserver;
021:
022:        import java.util.StringTokenizer;
023:
024:        public abstract class RequeteHTTP extends MessageHTTP {
025:
026:            /**
027:             * Nom de la methode (GET,POST ou HEAD)
028:             */
029:            private String methode;
030:
031:            /**
032:             * Url demandée par le client (ex.: /index.html)
033:             */
034:            private String url;
035:
036:            /**
037:             * Version du protocole utilisé (HTTP/1.0)
038:             */
039:            private String versionProtocole;
040:
041:            /**
042:             * Entete envoyée par le client (peut etre null)
043:             */
044:            private EnteteRequete enteteRequete;
045:
046:            /**
047:             * Entite renvoyée par le serveur
048:             */
049:            private EntiteHTTP entite;
050:
051:            /**
052:             * Créer une instance vide de RequeteHTTP
053:             */
054:            public RequeteHTTP() {
055:
056:            }
057:
058:            /**
059:             * Construit une Requete avec les parametres
060:             * 
061:             * @param methode
062:             *            nom de la methode
063:             * @param url
064:             *            url de la ressource demandée
065:             * @param version
066:             *            version du protocole
067:             */
068:            public RequeteHTTP(String methode, String url, String version) {
069:                this .methode = methode;
070:                this .url = url;
071:                this .versionProtocole = version;
072:            }
073:
074:            /**
075:             * Construit une requete a partir d'une chaine (envoyée par le client) (sans
076:             * gérer les eventuelles entetes envoyées par le client) (uniquement methode
077:             * GET !!!)
078:             * 
079:             * @param str
080:             *            la chaine envoyée
081:             * @return une instance de RequeteHTTP
082:             */
083:            public static RequeteHTTP getFromString(String str) {
084:                RequeteHTTP retour = null;
085:                String nomMethode = str.substring(0, str.indexOf(" "));
086:                // si la methode est GET ...
087:                if (nomMethode.equalsIgnoreCase("get")) {
088:                    String url, versionProtocole;
089:                    StringTokenizer st = new StringTokenizer(str, " ");
090:                    st.nextToken(); //lecture de la methode, on sait deja que c'est get
091:                    url = st.nextToken();
092:                    versionProtocole = st.nextToken();
093:                    if (st.hasMoreTokens()) {
094:                        // le reste est soit
095:                        // - des parametres supplementaires (http 1.1)
096:                        // - une EntiteHTTP (? dans une methode get ?)
097:                    }
098:                    retour = new RequeteGET(url, versionProtocole);
099:                } else {
100:                    // si la methode est POST ...
101:                    if (str.toUpperCase().startsWith("POST")) {
102:                        String url, versionProtocole;
103:                        StringTokenizer st = new StringTokenizer(str, " ");
104:                        st.nextToken(); //lecture de la methode, on sait deja que c'est get
105:                        url = st.nextToken();
106:                        versionProtocole = st.nextToken();
107:                        String ligneParam = "";
108:                        if (st.hasMoreTokens()) {
109:                            ligneParam = st.nextToken("\n");
110:                        }
111:                        System.out.println(ligneParam.toString());
112:                        retour = new RequetePOST(url, versionProtocole,
113:                                ligneParam.toString());
114:
115:                    } else {
116:                        // si la methode est HEAD...
117:                        if (str.toUpperCase().startsWith("HEAD")) {
118:                            String url, versionProtocole;
119:                            StringTokenizer st = new StringTokenizer(str, " ");
120:                            st.nextToken(); //lecture de la methode, on sait deja que c'est get
121:                            url = st.nextToken();
122:                            versionProtocole = st.nextToken();
123:                            retour = new RequeteHEAD(url, versionProtocole);
124:                        } else {
125:                            // la methode n'est pas geree
126:                            // lever une exception...
127:                            System.out
128:                                    .println("[erreur] Methode non implementee: "
129:                                            + nomMethode);
130:                        }
131:                    }
132:                }
133:
134:                return retour;
135:            }
136:
137:            /**
138:             * retourne l'url de la requte
139:             * @return
140:             */
141:            public String getUrl() {
142:                return this .url;
143:            }
144:
145:            /**
146:             * Initialise l'entete de la requete
147:             * @param entete
148:             */
149:            public void setEntete(EnteteRequete entete) {
150:                this .enteteRequete = entete;
151:            }
152:
153:            /**
154:             * Retourne la requete sous forme de chaine
155:             */
156:            public String toString() {
157:                String retour = new String(methode + " " + url + " "
158:                        + versionProtocole);
159:                if (this .enteteRequete != null)
160:                    retour = retour.concat("\n" + enteteRequete.toString());
161:                return retour;
162:            }
163:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.