Java Code Examples for io.netty.handler.codec.http.HttpConstants#COLON

The following examples show how to use io.netty.handler.codec.http.HttpConstants#COLON . 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: HttpPostMultipartRequestDecoder.java    From netty-4.1.22 with Apache License 2.0 6 votes vote down vote up
/**
 * Clean the String from any unallowed character 清除字符串中任何不允许的字符
 *
 * @return the cleaned String
 */
private static String cleanString(String field) {
    int size = field.length();
    StringBuilder sb = new StringBuilder(size);
    for (int i = 0; i < size; i++) {
        char nextChar = field.charAt(i);
        switch (nextChar) {
        case HttpConstants.COLON:
        case HttpConstants.COMMA:
        case HttpConstants.EQUALS:
        case HttpConstants.SEMICOLON:
        case HttpConstants.HT:
            sb.append(HttpConstants.SP_CHAR);
            break;
        case HttpConstants.DOUBLE_QUOTE:
            // nothing added, just removes it
            break;
        default:
            sb.append(nextChar);
            break;
        }
    }
    return sb.toString().trim();
}
 
Example 2
Source File: HttpPostMultipartRequestDecoder.java    From dorado with Apache License 2.0 6 votes vote down vote up
/**
 * Clean the String from any unallowed character
 *
 * @return the cleaned String
 */
private static String cleanString(String field) {
	int size = field.length();
	StringBuilder sb = new StringBuilder(size);
	for (int i = 0; i < size; i++) {
		char nextChar = field.charAt(i);
		switch (nextChar) {
		case HttpConstants.COLON:
		case HttpConstants.COMMA:
		case HttpConstants.EQUALS:
		case HttpConstants.SEMICOLON:
		case HttpConstants.HT:
			sb.append(HttpConstants.SP_CHAR);
			break;
		case HttpConstants.DOUBLE_QUOTE:
			// nothing added, just removes it
			break;
		default:
			sb.append(nextChar);
			break;
		}
	}
	return sb.toString().trim();
}
 
Example 3
Source File: HttpPostMultipartRequestDecoder.java    From netty4.0.27Learn with Apache License 2.0 6 votes vote down vote up
/**
 * Clean the String from any unallowed character
 *
 * @return the cleaned String
 */
@SuppressWarnings("IfStatementWithIdenticalBranches")
private static String cleanString(String field) {
    StringBuilder sb = new StringBuilder(field.length());
    for (int i = 0; i < field.length(); i++) {
        char nextChar = field.charAt(i);
        if (nextChar == HttpConstants.COLON) {
            sb.append(HttpConstants.SP);
        } else if (nextChar == HttpConstants.COMMA) {
            sb.append(HttpConstants.SP);
        } else if (nextChar == HttpConstants.EQUALS) {
            sb.append(HttpConstants.SP);
        } else if (nextChar == HttpConstants.SEMICOLON) {
            sb.append(HttpConstants.SP);
        } else if (nextChar == HttpConstants.HT) {
            sb.append(HttpConstants.SP);
        } else if (nextChar == HttpConstants.DOUBLE_QUOTE) {
            // nothing added, just removes it
        } else {
            sb.append(nextChar);
        }
    }
    return sb.toString().trim();
}