Java Code Examples for io.undertow.util.HttpString#length()
The following examples show how to use
io.undertow.util.HttpString#length() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HpackEncoder.java From lams with GNU General Public License v2.0 | 5 votes |
private void writeHuffmanEncodableName(ByteBuffer target, HttpString headerName) { if (hpackHeaderFunction.shouldUseHuffman(headerName)) { if(HPackHuffman.encode(target, headerName.toString(), true)) { return; } } target.put((byte) 0); //to use encodeInteger we need to place the first byte in the buffer. encodeInteger(target, headerName.length(), 7); for (int j = 0; j < headerName.length(); ++j) { target.put(Hpack.toLower(headerName.byteAt(j))); } }
Example 2
Source File: HpackEncoder.java From lams with GNU General Public License v2.0 | 5 votes |
TableEntry(HttpString name, String value, int position) { this.name = name; this.value = value; this.position = position; if (value != null) { this.size = 32 + name.length() + value.length(); } else { this.size = -1; } }
Example 3
Source File: Hpack.java From lams with GNU General Public License v2.0 | 5 votes |
HeaderField(HttpString name, String value) { this.name = name; this.value = value; if (value != null) { this.size = 32 + name.length() + value.length(); } else { this.size = -1; } }
Example 4
Source File: Connectors.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Verifies that the contents of the HttpString are a valid token according to rfc7230. * @param header The header to verify */ public static void verifyToken(HttpString header) { int length = header.length(); for(int i = 0; i < length; ++i) { byte c = header.byteAt(i); if(!ALLOWED_TOKEN_CHARACTERS[c]) { throw UndertowMessages.MESSAGES.invalidToken(c); } } }
Example 5
Source File: AjpUtils.java From lams with GNU General Public License v2.0 | 4 votes |
static void putHttpString(final ByteBuffer buf, HttpString value) { final int length = value.length(); putInt(buf, length); value.appendTo(buf); buf.put((byte) 0); }
Example 6
Source File: Http2HeaderBlockParser.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public void emitHeader(HttpString name, String value, boolean neverIndex) throws HpackException { if(maxHeaderListSize > 0) { headerSize += (name.length() + value.length() + 32); if (headerSize > maxHeaderListSize) { throw new HpackException(UndertowMessages.MESSAGES.headerBlockTooLarge(), Http2Channel.ERROR_PROTOCOL_ERROR); } } if(maxHeaders > 0 && headerMap.size() > maxHeaders) { return; } headerMap.add(name, value); if(name.length() == 0) { throw UndertowMessages.MESSAGES.invalidHeader(); } if(name.equals(Headers.TRANSFER_ENCODING)) { throw new HpackException(Http2Channel.ERROR_PROTOCOL_ERROR); } if(name.byteAt(0) == ':') { if(client) { if(!name.equals(Http2Channel.STATUS)) { invalid = true; } } else { if(!SERVER_HEADERS.contains(name)) { invalid = true; } } if(!processingPseudoHeaders) { throw new HpackException(UndertowMessages.MESSAGES.pseudoHeaderInWrongOrder(name), Http2Channel.ERROR_PROTOCOL_ERROR); } } else { processingPseudoHeaders = false; } for(int i = 0; i < name.length(); ++i) { byte c = name.byteAt(i); if(c>= 'A' && c <= 'Z') { invalid = true; UndertowLogger.REQUEST_LOGGER.debugf("Malformed request, header %s contains uppercase characters", name); } else if(c != ':' && !Connectors.isValidTokenCharacter(c)) { invalid = true; UndertowLogger.REQUEST_LOGGER.debugf("Malformed request, header %s contains invalid token character", name); } } }
Example 7
Source File: AjpServerResponseConduit.java From lams with GNU General Public License v2.0 | 4 votes |
private void putHttpString(final ByteBuffer buf, HttpString value) { final int length = value.length(); putInt(buf, length); value.appendTo(buf); buf.put((byte) 0); }