不像tomcat那样,jboss的sever信息,不能直接response.setHerder,因为这样会追加后边
Server Apache-Coyote/1.1,"SushilSaini"
jboss7 set "JAVA_OPTS=$JAVA_OPTS -Dorg.apache.coyote.http11.Http11Protocol.SERVER=JbossSecureServer"
jboss6 好像不好使哦
jboss6 好像不好使哦
/**
* When committing the response, we have to validate the set of headers, as
* well as setup the response filters.
*/
protected void prepareResponse() {
boolean entityBody = true;
contentDelimitation = false;
OutputFilter[] outputFilters = outputBuffer.getFilters();
if (http09 == true) {
// HTTP/0.9
outputBuffer.addActiveFilter
(outputFilters[Constants.IDENTITY_FILTER]);
return;
}
int statusCode = response.getStatus();
if ((statusCode == 204) || (statusCode == 205)
|| (statusCode == 304)) {
// No entity body
outputBuffer.addActiveFilter
(outputFilters[Constants.VOID_FILTER]);
entityBody = false;
contentDelimitation = true;
}
MessageBytes methodMB = request.method();
if (methodMB.equals("HEAD")) {
// No entity body
outputBuffer.addActiveFilter
(outputFilters[Constants.VOID_FILTER]);
contentDelimitation = true;
}
// Check for compression
boolean useCompression = false;
if (entityBody && (compressionLevel > 0)) {
useCompression = isCompressable();
// Change content-length to -1 to force chunking
if (useCompression) {
response.setContentLength(-1);
}
}
MimeHeaders headers = response.getMimeHeaders();
if (!entityBody) {
response.setContentLength(-1);
} else {
String contentType = response.getContentType();
if (contentType != null) {
headers.setValue("Content-Type").setString(contentType);
}
String contentLanguage = response.getContentLanguage();
if (contentLanguage != null) {
headers.setValue("Content-Language")
.setString(contentLanguage);
}
}
long contentLength = response.getContentLengthLong();
if (contentLength != -1) {
headers.setValue("Content-Length").setLong(contentLength);
outputBuffer.addActiveFilter
(outputFilters[Constants.IDENTITY_FILTER]);
contentDelimitation = true;
} else {
if (entityBody && http11 && (keepAlive || CHUNK_ON_CLOSE)) {
outputBuffer.addActiveFilter
(outputFilters[Constants.CHUNKED_FILTER]);
contentDelimitation = true;
headers.addValue(Constants.TRANSFERENCODING).setString(Constants.CHUNKED);
} else {
outputBuffer.addActiveFilter
(outputFilters[Constants.IDENTITY_FILTER]);
}
}
if (useCompression) {
outputBuffer.addActiveFilter(outputFilters[Constants.GZIP_FILTER]);
headers.setValue("Content-Encoding").setString("gzip");
// Make Proxies happy via Vary (from mod_deflate)
headers.addValue("Vary").setString("Accept-Encoding");
}
// Add date header
headers.setValue("Date").setString(FastHttpDateFormat.getCurrentDate());
// FIXME: Add transfer encoding header
if ((entityBody) && (!contentDelimitation)) {
// Mark as close the connection after the request, and add the
// connection: close header
keepAlive = false;
}
// If we know that the request is bad this early, add the
// Connection: close header.
keepAlive = keepAlive && !statusDropsConnection(statusCode);
if (!keepAlive) {
headers.addValue(Constants.CONNECTION).setString(Constants.CLOSE);
} else if (!http11 && !error) {
headers.addValue(Constants.CONNECTION).setString(Constants.KEEPALIVE);
}
// Build the response header
outputBuffer.sendStatus();
// Add server header
if (server != null) {因为,这块,他娘的给设置了一下,找了半天,源码是1640行,这不禁让我想起了,1640年是一个闰年,是农历庚辰年,是龙年。
年号:明思宗崇帧十三年。
headers.setValue("Server").setString(server);
} else {
outputBuffer.write(Constants.SERVER_BYTES);
}
int size = headers.size();
for (int i = 0; i < size; i++) {
outputBuffer.sendHeader(headers.getName(i), headers.getValue(i));
}
outputBuffer.endHeaders();
}