Skip to content

Commit 622d4d0

Browse files
[MOD] web:response-header: deprecated 'message' attribute dropped
1 parent 68e2daf commit 622d4d0

2 files changed

Lines changed: 10 additions & 30 deletions

File tree

basex-api/src/main/java/org/basex/http/HTTPConnection.java

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public ArrayList<MediaType> accepts() {
187187
*/
188188
public void error(final int code, final String info) throws IOException {
189189
log(code, info);
190-
status(code, null, info);
190+
status(code, info);
191191
}
192192

193193
/**
@@ -304,19 +304,17 @@ void stop(final JobException ex) throws IOException {
304304
response.getOutputStream().write(token(info));
305305
} catch(final IllegalStateException e) {
306306
// too late (response has already been committed)
307-
logError(code, null, info, e);
307+
logError(code, info, e);
308308
}
309309
}
310310

311311
/**
312312
* Sets a status and sends an info message.
313313
* @param code status code
314-
* @param message status message (can be {@code null})
315314
* @param body message for response body (can be {@code null})
316315
* @throws IOException I/O exception
317316
*/
318-
@SuppressWarnings("deprecation")
319-
public void status(final int code, final String message, final String body) throws IOException {
317+
public void status(final int code, final String body) throws IOException {
320318
try {
321319
response.resetBuffer();
322320
if(code == SC_UNAUTHORIZED && !response.containsHeader(WWW_AUTHENTICATE)) {
@@ -330,21 +328,13 @@ public void status(final int code, final String message, final String body) thro
330328
response.setHeader(WWW_AUTHENTICATE, header.toString());
331329
}
332330

333-
final int c = code < 0 || code > 999 ? 500 : code;
334-
if(message == null) {
335-
response.setStatus(c);
336-
} else {
337-
// do not allow Jetty to create a custom error html page
338-
// control characters and non-ASCII codes will be removed (GH-1632)
339-
response.setStatus(c, message.replaceAll("[^\\x20-\\x7F]", "?"));
340-
}
341-
331+
response.setStatus(code < 0 || code > 999 ? 500 : code);
342332
if(body != null) {
343333
response.setContentType(MediaType.TEXT_PLAIN + "; " + CHARSET + '=' + Strings.UTF8);
344334
response.getOutputStream().write(new TokenBuilder(token(body)).normalize().finish());
345335
}
346336
} catch(final IllegalStateException | IllegalArgumentException ex) {
347-
logError(code, message, body, ex);
337+
logError(code, body, ex);
348338
}
349339
}
350340

@@ -589,17 +579,13 @@ private String getRemoteAddr() {
589579
/**
590580
* Sets a status and sends an info message.
591581
* @param code status code
592-
* @param message status message (can be {@code null})
593582
* @param info detailed information (can be {@code null})
594583
* @param ex exception
595584
*/
596-
private void logError(final int code, final String message, final String info,
597-
final Exception ex) {
598-
585+
private void logError(final int code, final String info, final Exception ex) {
599586
final StringBuilder sb = new StringBuilder();
600587
sb.append("Code: ").append(code);
601588
if(info != null) sb.append(", Info: ").append(info);
602-
if(message != null) sb.append(", Message: ").append(message);
603589
sb.append(", Error: ").append(Util.message(ex));
604590
log(SC_INTERNAL_SERVER_ERROR, sb.toString());
605591
}

basex-api/src/main/java/org/basex/http/restxq/RestXqResponse.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ final class RestXqResponse extends WebResponse {
3737
private boolean registered;
3838
/** Function. */
3939
private RestXqFunction func;
40-
/** Status message. */
41-
private String message;
4240
/** Status code. */
4341
private Integer status;
4442
/** Forwarding. */
@@ -116,13 +114,12 @@ public Response serialize(final boolean body) throws QueryException, IOException
116114
if(status != null) {
117115
final int s = status;
118116
final StringBuilder msg = new StringBuilder();
119-
if(message != null) msg.append(message);
120117
if(s == 302) {
121118
if(!msg.isEmpty()) msg.append("; ");
122119
msg.append(HTTPText.LOCATION + ": ").append(conn.response.getHeader(HTTPText.LOCATION));
123120
}
124121
conn.log(s, msg.toString());
125-
conn.status(s, message, null);
122+
conn.status(s, null);
126123
}
127124

128125
// serialize result
@@ -178,17 +175,14 @@ private SerializerOptions build(final GNode response) throws QueryException {
178175
// process http:response element
179176
if(T_HTTP_RESPONSE.matches(node)) {
180177
// check status and reason
181-
byte[] sta = null, msg = null;
178+
byte[] sta = null;
182179
for(final GNode a : node.attributeIter()) {
183180
final QNm qnm = a.qname();
184181
if(qnm.eq(Q_STATUS)) sta = a.string();
185-
else if(qnm.eq(Q_REASON) || qnm.eq(Q_MESSAGE)) msg = a.string();
182+
else if(qnm.eq(Q_REASON) || qnm.eq(Q_MESSAGE)); // ignored
186183
else throw func.error(UNEXP_NODE_X, a);
187184
}
188-
if(sta != null) {
189-
status = toInt(sta);
190-
message = msg != null ? string(msg) : null;
191-
}
185+
if(sta != null) status = toInt(sta);
192186

193187
for(final GNode gchild : node.childIter()) {
194188
final XNode child = (XNode) gchild;

0 commit comments

Comments
 (0)