本文整理汇总了Java中org.apache.tomcat.util.http.HttpMessages类的典型用法代码示例。如果您正苦于以下问题:Java HttpMessages类的具体用法?Java HttpMessages怎么用?Java HttpMessages使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HttpMessages类属于org.apache.tomcat.util.http包,在下文中一共展示了HttpMessages类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: InternalAprOutputBuffer
import org.apache.tomcat.util.http.HttpMessages; //导入依赖的package包/类
/**
* Default constructor.
*/
public InternalAprOutputBuffer(Response response, int headerBufferSize) {
this.response = response;
buf = new byte[headerBufferSize];
if (headerBufferSize < (8 * 1024)) {
bbuf = ByteBuffer.allocateDirect(6 * 1500);
} else {
bbuf = ByteBuffer.allocateDirect((headerBufferSize / 1500 + 1) * 1500);
}
outputStreamOutputBuffer = new SocketOutputBuffer();
filterLibrary = new OutputFilter[0];
activeFilters = new OutputFilter[0];
lastActiveFilter = -1;
committed = false;
finished = false;
// Cause loading of HttpMessages
HttpMessages.getInstance(response.getLocale()).getMessage(200);
}
示例2: AjpProcessor
import org.apache.tomcat.util.http.HttpMessages; //导入依赖的package包/类
public AjpProcessor(int packetSize, JIoEndpoint endpoint) {
this.endpoint = endpoint;
request = new Request();
request.setInputBuffer(new SocketInputBuffer());
response = new Response();
response.setHook(this);
response.setOutputBuffer(new SocketOutputBuffer());
request.setResponse(response);
requestHeaderMessage = new AjpMessage(packetSize);
responseHeaderMessage = new AjpMessage(packetSize);
bodyMessage = new AjpMessage(packetSize);
// Set the get body message buffer
AjpMessage getBodyMessage = new AjpMessage(16);
getBodyMessage.reset();
getBodyMessage.appendByte(Constants.JK_AJP13_GET_BODY_CHUNK);
getBodyMessage.appendInt(packetSize - Constants.READ_HEAD_LEN);
getBodyMessage.end();
getBodyMessageArray = new byte[getBodyMessage.getLen()];
System.arraycopy(getBodyMessage.getBuffer(), 0, getBodyMessageArray,
0, getBodyMessage.getLen());
// Cause loading of HexUtils
int foo = HexUtils.DEC[0];
// Cause loading of HttpMessages
HttpMessages.getMessage(200);
}
示例3: InternalAprOutputBuffer
import org.apache.tomcat.util.http.HttpMessages; //导入依赖的package包/类
/**
* Default constructor.
*/
public InternalAprOutputBuffer(Response response, int headerBufferSize) {
this.response = response;
buf = new byte[headerBufferSize];
if (headerBufferSize < (8 * 1024)) {
bbuf = ByteBuffer.allocateDirect(6 * 1500);
} else {
bbuf = ByteBuffer.allocateDirect((headerBufferSize / 1500 + 1) * 1500);
}
outputStreamOutputBuffer = new SocketOutputBuffer();
filterLibrary = new OutputFilter[0];
activeFilters = new OutputFilter[0];
lastActiveFilter = -1;
committed = false;
finished = false;
// Cause loading of HttpMessages
HttpMessages.getInstance(response.getLocale()).getMessage(200);
}
示例4: InternalAprOutputBuffer
import org.apache.tomcat.util.http.HttpMessages; //导入依赖的package包/类
/**
* Default constructor.
*/
public InternalAprOutputBuffer(Response response, int headerBufferSize) {
this.response = response;
buf = new byte[headerBufferSize];
if (headerBufferSize < (8 * 1024)) {
bbuf = ByteBuffer.allocateDirect(6 * 1500);
} else {
bbuf = ByteBuffer.allocateDirect((headerBufferSize / 1500 + 1) * 1500);
}
outputStreamOutputBuffer = new SocketOutputBuffer();
filterLibrary = new OutputFilter[0];
activeFilters = new OutputFilter[0];
lastActiveFilter = -1;
committed = false;
finished = false;
// Cause loading of HttpMessages
HttpMessages.getMessage(200);
}
示例5: encode
import org.apache.tomcat.util.http.HttpMessages; //导入依赖的package包/类
protected String encode(String value, String encoding) {
String retVal = null;
if (encoding.equalsIgnoreCase("url")) {
retVal = urlEncoder.encode(value, "UTF-8");
} else if (encoding.equalsIgnoreCase("none")) {
retVal = value;
} else if (encoding.equalsIgnoreCase("entity")) {
retVal = HttpMessages.filter(value);
} else {
//This shouldn't be possible
throw new IllegalArgumentException("Unknown encoding: " + encoding);
}
return retVal;
}
示例6: encode
import org.apache.tomcat.util.http.HttpMessages; //导入依赖的package包/类
protected String encode(String value, String encoding) {
String retVal = null;
if (encoding.equalsIgnoreCase("url")) {
retVal = urlEncoder.encode(value);
} else if (encoding.equalsIgnoreCase("none")) {
retVal = value;
} else if (encoding.equalsIgnoreCase("entity")) {
retVal = HttpMessages.filter(value);
} else {
//This shouldn't be possible
throw new IllegalArgumentException("Unknown encoding: " + encoding);
}
return retVal;
}
示例7: AjpAprProcessor
import org.apache.tomcat.util.http.HttpMessages; //导入依赖的package包/类
public AjpAprProcessor(int packetSize, AprEndpoint endpoint) {
this.endpoint = endpoint;
request = new Request();
request.setInputBuffer(new SocketInputBuffer());
response = new Response();
response.setHook(this);
response.setOutputBuffer(new SocketOutputBuffer());
request.setResponse(response);
requestHeaderMessage = new AjpMessage(packetSize);
responseHeaderMessage = new AjpMessage(packetSize);
bodyMessage = new AjpMessage(packetSize);
// Allocate input and output buffers
inputBuffer = ByteBuffer.allocateDirect(packetSize * 2);
inputBuffer.limit(0);
outputBuffer = ByteBuffer.allocateDirect(packetSize * 2);
// Set the get body message buffer
AjpMessage getBodyMessage = new AjpMessage(16);
getBodyMessage.reset();
getBodyMessage.appendByte(Constants.JK_AJP13_GET_BODY_CHUNK);
getBodyMessage.appendInt(packetSize - Constants.READ_HEAD_LEN);
getBodyMessage.end();
getBodyMessageBuffer =
ByteBuffer.allocateDirect(getBodyMessage.getLen());
getBodyMessageBuffer.put(getBodyMessage.getBuffer(), 0,
getBodyMessage.getLen());
// Cause loading of HexUtils
int foo = HexUtils.DEC[0];
// Cause loading of HttpMessages
HttpMessages.getMessage(200);
}
示例8: getMessage
import org.apache.tomcat.util.http.HttpMessages; //导入依赖的package包/类
private String getMessage(final int message){
if (org.apache.coyote.Constants.IS_SECURITY_ENABLED){
return (String)AccessController.doPrivileged(
new PrivilegedAction(){
public Object run(){
return HttpMessages.getMessage(message);
}
}
);
} else {
return HttpMessages.getMessage(message);
}
}
示例9: InternalAprOutputBuffer
import org.apache.tomcat.util.http.HttpMessages; //导入依赖的package包/类
/**
* Alternate constructor.
*/
public InternalAprOutputBuffer(Response response, int headerBufferSize, AprEndpoint endpoint) {
this.response = response;
this.endpoint = endpoint;
headers = response.getMimeHeaders();
buf = new byte[headerBufferSize];
if (headerBufferSize < (8 * 1024)) {
bbuf = ByteBuffer.allocateDirect(6 * 1500);
} else {
bbuf = ByteBuffer.allocateDirect((headerBufferSize / 1500 + 1) * 1500);
}
outputStreamOutputBuffer = new SocketOutputBuffer();
filterLibrary = new OutputFilter[0];
activeFilters = new OutputFilter[0];
lastActiveFilter = -1;
committed = false;
finished = false;
leftover = new ByteChunk();
nonBlocking = false;
// Cause loading of HttpMessages
HttpMessages.getMessage(200);
}
示例10: encode
import org.apache.tomcat.util.http.HttpMessages; //导入依赖的package包/类
protected String encode(String value, String encoding) {
String retVal = null;
if (encoding.equalsIgnoreCase("url")) {
retVal = urlEncoder.encode(value, "UTF-8");
} else if (encoding.equalsIgnoreCase("none")) {
retVal = value;
} else if (encoding.equalsIgnoreCase("entity")) {
retVal = HttpMessages.filter(value);
} else {
// This shouldn't be possible
throw new IllegalArgumentException("Unknown encoding: " + encoding);
}
return retVal;
}
示例11: sendStatus
import org.apache.tomcat.util.http.HttpMessages; //导入依赖的package包/类
/**
* Send the response status line.
*/
public void sendStatus() {
// Write protocol name
write(Constants.HTTP_11_BYTES);
buf[pos++] = Constants.SP;
// Write status code
int status = response.getStatus();
switch (status) {
case 200:
write(Constants._200_BYTES);
break;
case 400:
write(Constants._400_BYTES);
break;
case 404:
write(Constants._404_BYTES);
break;
default:
write(status);
}
buf[pos++] = Constants.SP;
// Write message
String message = null;
if (org.apache.coyote.Constants.USE_CUSTOM_STATUS_MSG_IN_HEADER &&
HttpMessages.isSafeInHttpHeader(response.getMessage())) {
message = response.getMessage();
}
if (message == null) {
write(HttpMessages.getInstance(
response.getLocale()).getMessage(status));
} else {
write(message);
}
// End the response status line
if (org.apache.coyote.Constants.IS_SECURITY_ENABLED){
AccessController.doPrivileged(
new PrivilegedAction<Void>(){
@Override
public Void run(){
buf[pos++] = Constants.CR;
buf[pos++] = Constants.LF;
return null;
}
}
);
} else {
buf[pos++] = Constants.CR;
buf[pos++] = Constants.LF;
}
}
示例12: InternalNioOutputBuffer
import org.apache.tomcat.util.http.HttpMessages; //导入依赖的package包/类
/**
* Default constructor.
*/
public InternalNioOutputBuffer(Response response, int headerBufferSize) {
this.response = response;
buf = new byte[headerBufferSize];
outputStreamOutputBuffer = new SocketOutputBuffer();
filterLibrary = new OutputFilter[0];
activeFilters = new OutputFilter[0];
lastActiveFilter = -1;
committed = false;
finished = false;
// Cause loading of HttpMessages
HttpMessages.getInstance(response.getLocale()).getMessage(200);
}
示例13: prepareResponse
import org.apache.tomcat.util.http.HttpMessages; //导入依赖的package包/类
/**
* When committing the response, we have to validate the set of headers, as
* well as setup the response filters.
*/
protected void prepareResponse()
throws IOException {
response.setCommitted(true);
responseHeaderMessage.reset();
responseHeaderMessage.appendByte(Constants.JK_AJP13_SEND_HEADERS);
// HTTP header contents
responseHeaderMessage.appendInt(response.getStatus());
String message = null;
if (org.apache.coyote.Constants.USE_CUSTOM_STATUS_MSG_IN_HEADER) {
message = response.getMessage();
}
if (message == null){
message = HttpMessages.getMessage(response.getStatus());
} else {
message = message.replace('\n', ' ').replace('\r', ' ');
}
if (message == null) {
// Many httpd 2.x wants a non empty status message
message = Integer.toString(response.getStatus());
}
tmpMB.setString(message);
responseHeaderMessage.appendBytes(tmpMB);
// Special headers
MimeHeaders headers = response.getMimeHeaders();
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);
}
int contentLength = response.getContentLength();
if (contentLength >= 0) {
headers.setValue("Content-Length").setInt(contentLength);
}
// Other headers
int numHeaders = headers.size();
responseHeaderMessage.appendInt(numHeaders);
for (int i = 0; i < numHeaders; i++) {
MessageBytes hN = headers.getName(i);
int hC = Constants.getResponseAjpIndex(hN.toString());
if (hC > 0) {
responseHeaderMessage.appendInt(hC);
}
else {
responseHeaderMessage.appendBytes(hN);
}
MessageBytes hV=headers.getValue(i);
responseHeaderMessage.appendBytes(hV);
}
// Write to buffer
responseHeaderMessage.end();
outputBuffer.put(responseHeaderMessage.getBuffer(), 0, responseHeaderMessage.getLen());
}
示例14: prepareResponse
import org.apache.tomcat.util.http.HttpMessages; //导入依赖的package包/类
/**
* When committing the response, we have to validate the set of headers, as
* well as setup the response filters.
*/
protected void prepareResponse()
throws IOException {
response.setCommitted(true);
responseHeaderMessage.reset();
responseHeaderMessage.appendByte(Constants.JK_AJP13_SEND_HEADERS);
// HTTP header contents
responseHeaderMessage.appendInt(response.getStatus());
String message = null;
if (org.apache.coyote.Constants.USE_CUSTOM_STATUS_MSG_IN_HEADER) {
message = response.getMessage();
}
if (message == null){
message = HttpMessages.getMessage(response.getStatus());
} else {
message = message.replace('\n', ' ').replace('\r', ' ');
}
if (message == null) {
// Many httpd 2.x wants a non empty status message
message = Integer.toString(response.getStatus());
}
tmpMB.setString(message);
responseHeaderMessage.appendBytes(tmpMB);
// Special headers
MimeHeaders headers = response.getMimeHeaders();
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);
}
int contentLength = response.getContentLength();
if (contentLength >= 0) {
headers.setValue("Content-Length").setInt(contentLength);
}
// Other headers
int numHeaders = headers.size();
responseHeaderMessage.appendInt(numHeaders);
for (int i = 0; i < numHeaders; i++) {
MessageBytes hN = headers.getName(i);
int hC = Constants.getResponseAjpIndex(hN.toString());
if (hC > 0) {
responseHeaderMessage.appendInt(hC);
}
else {
responseHeaderMessage.appendBytes(hN);
}
MessageBytes hV=headers.getValue(i);
responseHeaderMessage.appendBytes(hV);
}
// Write to buffer
responseHeaderMessage.end();
output.write(responseHeaderMessage.getBuffer(), 0, responseHeaderMessage.getLen());
}
示例15: sendStatus
import org.apache.tomcat.util.http.HttpMessages; //导入依赖的package包/类
/**
* Send the response status line.
*/
public void sendStatus() {
// Write protocol name
write(Constants.HTTP_11_BYTES);
buf[pos++] = Constants.SP;
// Write status code
int status = response.getStatus();
switch (status) {
case 200:
write(Constants._200_BYTES);
break;
case 400:
write(Constants._400_BYTES);
break;
case 404:
write(Constants._404_BYTES);
break;
default:
write(status);
}
buf[pos++] = Constants.SP;
// Write message
String message = null;
if (org.apache.coyote.Constants.USE_CUSTOM_STATUS_MSG_IN_HEADER) {
message = response.getMessage();
}
if (message == null) {
write(HttpMessages.getMessage(status));
} else {
write(message.replace('\n', ' ').replace('\r', ' '));
}
// End the response status line
buf[pos++] = Constants.CR;
buf[pos++] = Constants.LF;
}