Skip to content

Commit 31e625a

Browse files
committed
Automatically set http servlet response character encoding to UTF-8.
1 parent 99ac90d commit 31e625a

6 files changed

Lines changed: 60 additions & 0 deletions

File tree

src/main/java/org/swordapp/server/CollectionAPI.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ public CollectionAPI(CollectionListManager clm, CollectionDepositManager cdm, Sw
3232
public void get(HttpServletRequest req, HttpServletResponse resp)
3333
throws ServletException, IOException
3434
{
35+
// let the superclass prepare the request/response objects
36+
super.get(req, resp);
37+
3538
// first find out if this is supported
3639
if (this.clm == null)
3740
{
@@ -100,6 +103,9 @@ public void get(HttpServletRequest req, HttpServletResponse resp)
100103
public void post(HttpServletRequest req, HttpServletResponse resp)
101104
throws ServletException, IOException
102105
{
106+
// let the superclass prepare the request/response objects
107+
super.post(req, resp);
108+
103109
// do the initial authentication
104110
AuthCredentials auth = null;
105111
try

src/main/java/org/swordapp/server/ContainerAPI.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ public void get(HttpServletRequest req, HttpServletResponse resp)
3838
public void get(HttpServletRequest req, HttpServletResponse resp, boolean sendBody)
3939
throws ServletException, IOException
4040
{
41+
// let the superclass prepare the request/response objects
42+
super.get(req, resp);
43+
4144
// do the initial authentication
4245
AuthCredentials auth = null;
4346
try
@@ -157,6 +160,9 @@ public void head(HttpServletRequest req, HttpServletResponse resp)
157160
public void put(HttpServletRequest req, HttpServletResponse resp)
158161
throws ServletException, IOException
159162
{
163+
// let the superclass prepare the request/response objects
164+
super.put(req, resp);
165+
160166
// do the initial authentication
161167
AuthCredentials auth = null;
162168
try
@@ -294,6 +300,9 @@ else if (isEntryOnly)
294300
public void post(HttpServletRequest req, HttpServletResponse resp)
295301
throws ServletException, IOException
296302
{
303+
// let the superclass prepare the request/response objects
304+
super.post(req, resp);
305+
297306
// do the initial authentication
298307
AuthCredentials auth = null;
299308
try
@@ -429,6 +438,9 @@ else if (headersOnly)
429438
public void delete(HttpServletRequest req, HttpServletResponse resp)
430439
throws ServletException, IOException
431440
{
441+
// let the superclass prepare the request/response objects
442+
super.delete(req, resp);
443+
432444
// do the initial authentication
433445
AuthCredentials auth = null;
434446
try

src/main/java/org/swordapp/server/MediaResourceAPI.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ public void get(HttpServletRequest req, HttpServletResponse resp)
3636
public void get(HttpServletRequest req, HttpServletResponse resp, boolean sendBody)
3737
throws ServletException, IOException
3838
{
39+
// let the superclass prepare the request/response objects
40+
super.get(req, resp);
41+
3942
// do the initial authentication
4043
AuthCredentials auth = null;
4144
try
@@ -135,6 +138,9 @@ public void head(HttpServletRequest req, HttpServletResponse resp)
135138
public void put(HttpServletRequest req, HttpServletResponse resp)
136139
throws ServletException, IOException
137140
{
141+
// let the superclass prepare the request/response objects
142+
super.put(req, resp);
143+
138144
// do the initial authentication
139145
AuthCredentials auth = null;
140146
try
@@ -205,6 +211,9 @@ public void put(HttpServletRequest req, HttpServletResponse resp)
205211
public void post(HttpServletRequest req, HttpServletResponse resp)
206212
throws ServletException, IOException
207213
{
214+
// let the superclass prepare the request/response objects
215+
super.post(req, resp);
216+
208217
// do the initial authentication
209218
AuthCredentials auth = null;
210219
try
@@ -305,6 +314,9 @@ public void post(HttpServletRequest req, HttpServletResponse resp)
305314
public void delete(HttpServletRequest req, HttpServletResponse resp)
306315
throws ServletException, IOException
307316
{
317+
// let the superclass prepare the request/response objects
318+
super.delete(req, resp);
319+
308320
// do the initial authentication
309321
AuthCredentials auth = null;
310322
try

src/main/java/org/swordapp/server/ServiceDocumentAPI.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ public ServiceDocumentAPI(ServiceDocumentManager sdm, SwordConfiguration config)
2323
public void get(HttpServletRequest req, HttpServletResponse resp)
2424
throws ServletException, IOException
2525
{
26+
// let the superclass prepare the request/response objects
27+
super.get(req, resp);
28+
2629
// do the initial authentication
2730
AuthCredentials auth = null;
2831
try

src/main/java/org/swordapp/server/StatementAPI.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ public StatementAPI(StatementManager sm, SwordConfiguration config)
2727
public void get(HttpServletRequest req, HttpServletResponse resp)
2828
throws ServletException, IOException
2929
{
30+
// let the superclass prepare the request/response objects
31+
super.get(req, resp);
32+
3033
// do the initial authentication
3134
AuthCredentials auth = null;
3235
try

src/main/java/org/swordapp/server/SwordAPIEndpoint.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,30 @@ protected SwordAPIEndpoint(SwordConfiguration config)
3535
this.config = config;
3636
}
3737

38+
public void get(HttpServletRequest req, HttpServletResponse resp)
39+
throws ServletException, IOException
40+
{
41+
resp.setCharacterEncoding("UTF-8");
42+
}
43+
44+
public void post(HttpServletRequest req, HttpServletResponse resp)
45+
throws ServletException, IOException
46+
{
47+
resp.setCharacterEncoding("UTF-8");
48+
}
49+
50+
public void put(HttpServletRequest req, HttpServletResponse resp)
51+
throws ServletException, IOException
52+
{
53+
resp.setCharacterEncoding("UTF-8");
54+
}
55+
56+
public void delete(HttpServletRequest req, HttpServletResponse resp)
57+
throws ServletException, IOException
58+
{
59+
resp.setCharacterEncoding("UTF-8");
60+
}
61+
3862
protected AuthCredentials getAuthCredentials(HttpServletRequest request)
3963
throws SwordAuthException
4064
{

0 commit comments

Comments
 (0)