Browse Source

Netty plaintext test

Patrick Falls 12 years ago
parent
commit
61c3fd1b07
1 changed files with 16 additions and 12 deletions
  1. 16 12
      netty/src/main/java/hello/HelloServerHandler.java

+ 16 - 12
netty/src/main/java/hello/HelloServerHandler.java

@@ -57,18 +57,22 @@ public class HelloServerHandler extends ChannelInboundMessageHandlerAdapter<Obje
             if (is100ContinueExpected(request)) {
                 send100Continue(out);
             }
-            
-            Map<String, String> data = new HashMap<String, String>();
-            data.put("message", "Hello, world");
-            
-            buf.setLength(0);
-            try
-            {
-              buf.append(HelloServerHandler.mapper.writeValueAsString(data));
-            }
-            catch (IOException ex)
-            {
-              // do nothing
+
+            if("/plaintext".equals(request.getUri())) {
+                buf.append("Hello, World!");
+            } else {
+                Map<String, String> data = new HashMap<String, String>();
+                data.put("message", "Hello, world");
+                
+                buf.setLength(0);
+                try
+                {
+                  buf.append(HelloServerHandler.mapper.writeValueAsString(data));
+                }
+                catch (IOException ex)
+                {
+                  // do nothing
+                }
             }
 
             appendDecoderResult(buf, request);