use of org.glassfish.grizzly.http.util.B2CConverter in project Payara by payara.
the class Request method convertURI.
// START CR 6309511
/**
* Character conversion of the URI.
*/
protected void convertURI(MessageBytes uri) throws Exception {
ByteChunk bc = uri.getByteChunk();
CharChunk cc = uri.getCharChunk();
int length = bc.getLength();
cc.allocate(length, -1);
String enc = connector.getURIEncoding();
if (enc != null && !enc.isEmpty() && !Globals.ISO_8859_1_ENCODING.equalsIgnoreCase(enc)) {
B2CConverter conv = getURIConverter();
try {
if (conv == null) {
conv = new B2CConverter(enc);
setURIConverter(conv);
}
} catch (IOException e) {
// Ignore
log.log(Level.SEVERE, LogFacade.INVALID_URI_ENCODING);
connector.setURIEncoding(null);
}
if (conv != null) {
try {
conv.convert(bc, cc, cc.getBuffer().length - cc.getEnd());
uri.setChars(cc.getBuffer(), cc.getStart(), cc.getLength());
return;
} catch (IOException e) {
log.log(Level.SEVERE, LogFacade.INVALID_URI_CHAR_ENCODING);
cc.recycle();
}
}
}
// Default encoding: fast conversion
byte[] bbuf = bc.getBuffer();
char[] cbuf = cc.getBuffer();
int start = bc.getStart();
for (int i = 0; i < length; i++) {
cbuf[i] = (char) (bbuf[i + start] & 0xff);
}
uri.setChars(cbuf, 0, length);
}
Aggregations