简体   繁体   中英

WildFly 8.2 and 304 Not Modified

RFC 2616 - "All 1xx (informational), 204 (no content), and 304 (not modified) responses MUST NOT include a message-body."

After upgrading to WildFly 8.2 from JBoss 5.1, load balancer (written with Netty 4.0) broke.

Cause - WildFly sends response with message-body on 304 error:

<html><head><title>Error</title></head><body>Not Modified</body></html>

Netty in accordance with RFC 2616 reads only header for 304, but ignore not zero Content-Length and left body in socket, so we get error on second read from same channel.

I can fix that by changing response.sendError(304) to response.setStatus(304), but want to know, is that possible to configure WildFly to not send message-body on 304 Not Modified error?

Technically, 2xx and 3xx are not errors. Only response codes in the ranges 4xx and 5xx are errors (client errors and server errors, respectively). So, I'd argue that setStatus is indeed the correct one.

As you are telling the server that you are sending an error, but not including a body, the server is including one itself. This is because errors (4xx and 5xx) have this requirement:

Except when responding to a HEAD request, the server SHOULD send a representation containing an explanation of the error situation, and whether it is a temporary or permanent condition.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM