Skip to content

Commit d9f3ca8

Browse files
committed
PR #655 - Add some improvements as in PR #636 (Grizzly)
1 parent e76c9a6 commit d9f3ca8

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

wicket/src/main/java/hellowicket/plaintext/HelloTextResource.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package hellowicket.plaintext;
22

3+
import java.nio.charset.Charset;
4+
35
import org.apache.wicket.request.resource.AbstractResource;
46

57
/**
@@ -10,15 +12,18 @@ public class HelloTextResource extends AbstractResource
1012
{
1113
private static final long serialVersionUID = 1L;
1214

15+
private static final String CONTENT_TYPE = "text/plain";
16+
private static final byte[] DATA = "Hello, World!".getBytes(Charset.forName("UTF-8"));
17+
1318
protected ResourceResponse newResourceResponse(Attributes attributes)
1419
{
1520
ResourceResponse response = new ResourceResponse();
16-
response.setContentType("text/plain");
17-
response.setContentLength(13);
21+
response.setContentType(CONTENT_TYPE);
22+
response.setContentLength(DATA.length);
1823
response.setWriteCallback(new WriteCallback() {
1924
public void writeData(Attributes attributes)
2025
{
21-
attributes.getResponse().write("Hello, World!");
26+
attributes.getResponse().write(DATA);
2227
}
2328
});
2429
return response;

0 commit comments

Comments
 (0)