Example usage for io.netty.util AsciiString startsWith

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

Introduction

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

Prototype

public boolean startsWith(CharSequence prefix) 

Source Link

Document

Compares the specified string to this string to determine if the specified string is a prefix.

Usage

From source file:io.jsync.http.impl.DefaultHttpServerRequest.java

License:Open Source License

@Override
public HttpServerRequest expectMultiPart(boolean expect) {
    if (expect) {
        String contentType = request.headers().get(HttpHeaderNames.CONTENT_TYPE);
        if (contentType != null) {
            HttpMethod method = request.method();
            AsciiString lowerCaseContentType = new AsciiString(contentType.toLowerCase());
            boolean isURLEncoded = lowerCaseContentType
                    .startsWith(HttpHeaderValues.APPLICATION_X_WWW_FORM_URLENCODED);
            if ((lowerCaseContentType.startsWith(HttpHeaderValues.MULTIPART_FORM_DATA) || isURLEncoded)
                    && (method.equals(HttpMethod.POST) || method.equals(HttpMethod.PUT)
                            || method.equals(HttpMethod.PATCH))) {
                decoder = new HttpPostRequestDecoder(new DataFactory(), request);
            }/*from w  w w.j  a  v a2 s  .  co  m*/
        }
    } else {
        decoder = null;
    }
    return this;
}