Example usage for io.netty.util AsciiString contentEqualsIgnoreCase

List of usage examples for io.netty.util AsciiString contentEqualsIgnoreCase

Introduction

In this page you can find the example usage for io.netty.util AsciiString contentEqualsIgnoreCase.

Prototype

public static boolean contentEqualsIgnoreCase(CharSequence a, CharSequence b) 

Source Link

Document

Returns true if both CharSequence 's are equals when ignore the case.

Usage

From source file:com.linecorp.armeria.internal.ArmeriaHttpUtil.java

License:Apache License

/**
 * Filter the {@link HttpHeaderNames#TE} header according to the
 * <a href="https://tools.ietf.org/html/rfc7540#section-8.1.2.2">special rules in the HTTP/2 RFC</a>.
 * @param entry An entry whose name is {@link HttpHeaderNames#TE}.
 * @param out the resulting HTTP/2 headers.
 *///  w w w  .j a va 2 s  .  co m
private static void toHttp2HeadersFilterTE(Entry<CharSequence, CharSequence> entry, HttpHeaders out) {
    if (AsciiString.indexOf(entry.getValue(), ',', 0) == -1) {
        if (AsciiString.contentEqualsIgnoreCase(AsciiString.trim(entry.getValue()),
                HttpHeaderValues.TRAILERS)) {
            out.add(HttpHeaderNames.TE, HttpHeaderValues.TRAILERS.toString());
        }
    } else {
        final List<CharSequence> teValues = StringUtil.unescapeCsvFields(entry.getValue());
        for (CharSequence teValue : teValues) {
            if (AsciiString.contentEqualsIgnoreCase(AsciiString.trim(teValue), HttpHeaderValues.TRAILERS)) {
                out.add(HttpHeaderNames.TE, HttpHeaderValues.TRAILERS.toString());
                break;
            }
        }
    }
}

From source file:io.vertx.core.http.impl.headers.VertxHttpHeaders.java

License:Open Source License

@Override
public boolean contains(CharSequence name, CharSequence value, boolean ignoreCase) {
    int h = AsciiString.hashCode(name);
    int i = index(h);
    VertxHttpHeaders.MapEntry e = entries[i];
    HashingStrategy<CharSequence> strategy = ignoreCase ? CASE_INSENSITIVE_HASHER : CASE_SENSITIVE_HASHER;
    while (e != null) {
        if (e.hash == h && AsciiString.contentEqualsIgnoreCase(name, e.key)) {
            if (strategy.equals(value, e.getValue())) {
                return true;
            }/* w w w  .j  a  v  a 2s . c  o  m*/
        }
        e = e.next;
    }
    return false;
}

From source file:io.vertx.core.http.impl.headers.VertxHttpHeaders.java

License:Open Source License

@Override
public List<String> getAll(CharSequence name) {
    Objects.requireNonNull(name, "name");

    LinkedList<String> values = new LinkedList<>();

    int h = AsciiString.hashCode(name);
    int i = index(h);
    VertxHttpHeaders.MapEntry e = entries[i];
    while (e != null) {
        if (e.hash == h && AsciiString.contentEqualsIgnoreCase(name, e.key)) {
            values.addFirst(e.getValue().toString());
        }//from w w w .j av a2 s .c o m
        e = e.next;
    }
    return values;
}

From source file:io.vertx.core.http.impl.headers.VertxHttpHeaders.java

License:Open Source License

private void remove0(int h, int i, CharSequence name) {
    VertxHttpHeaders.MapEntry e = entries[i];
    if (e == null) {
        return;/*from  ww w  .  j av a  2  s  .  c  om*/
    }

    for (;;) {
        if (e.hash == h && AsciiString.contentEqualsIgnoreCase(name, e.key)) {
            e.remove();
            VertxHttpHeaders.MapEntry next = e.next;
            if (next != null) {
                entries[i] = next;
                e = next;
            } else {
                entries[i] = null;
                return;
            }
        } else {
            break;
        }
    }

    for (;;) {
        VertxHttpHeaders.MapEntry next = e.next;
        if (next == null) {
            break;
        }
        if (next.hash == h && AsciiString.contentEqualsIgnoreCase(name, next.key)) {
            e.next = next.next;
            next.remove();
        } else {
            e = next;
        }
    }
}

From source file:io.vertx.core.http.impl.headers.VertxHttpHeaders.java

License:Open Source License

private CharSequence get0(CharSequence name) {
    int h = AsciiString.hashCode(name);
    int i = index(h);
    VertxHttpHeaders.MapEntry e = entries[i];
    while (e != null) {
        if (e.hash == h && AsciiString.contentEqualsIgnoreCase(name, e.key)) {
            return e.getValue();
        }/*from  w  w  w.j a v  a2  s .  c o m*/
        e = e.next;
    }
    return null;
}