Changeset 1088
- Timestamp:
- 06/12/08 01:00:39 (3 months ago)
- Files:
-
- trunk/example/net/servlets.d (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/example/net/servlets.d
r1079 r1088 33 33 tango.util.log.Config; 34 34 35 import tango.net.http.HttpCookies; 36 35 37 // for testing the http server 36 38 import mango.net.http.server.HttpServer; … … 85 87 if (! response.copyFile (request.context, request.pathInfo)) 86 88 logger.warn ("cannot locate file: " ~ request.uri.getPath); 89 } 90 } 91 92 93 /******************************************************************************* 94 95 Servlet to return a file. 96 97 *******************************************************************************/ 98 99 class CookieServlet : MethodServlet 100 { 101 /*********************************************************************** 102 103 support GET requests only! All other method requests will 104 return an error to the user-agent 105 106 ***********************************************************************/ 107 108 void doGet (IServletRequest request, IServletResponse response) 109 { 110 scope cook = new Cookie("echo_cookie", "'some/value'"); 111 //cook.setDomain("apple.com"); 112 cook.setPath("/"); 113 response.cookies.add(cook); 114 115 response.buffer.append ("you have a cookie"); 116 response.setStatus(HttpResponses.OK); 87 117 } 88 118 } … … 215 245 auto example = sp.addContext (new ServletContext ("/example")); 216 246 247 // map cookie requests to our cookie servlet 248 sp.addMapping ("/cookie", sp.addServlet (new CookieServlet, example)); 249 217 250 // map echo requests to our echo servlet 218 251 sp.addMapping ("/echo", sp.addServlet (new Echo, example));
