All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.linecorp.armeria.common.DefaultRequestHeaders Maven / Gradle / Ivy

Go to download

Asynchronous HTTP/2 RPC/REST client/server library built on top of Java 8, Netty, Thrift and gRPC (armeria)

There is a newer version: 1.30.1
Show newest version
/*
 * Copyright 2019 LINE Corporation
 *
 * LINE Corporation licenses this file to you under the Apache License,
 * version 2.0 (the "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at:
 *
 *   https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */
package com.linecorp.armeria.common;

import java.net.URI;
import java.util.List;
import java.util.Locale;
import java.util.Locale.LanguageRange;

import javax.annotation.Nullable;

@SuppressWarnings({ "checkstyle:EqualsHashCode", "EqualsAndHashcode" })
final class DefaultRequestHeaders extends DefaultHttpHeaders implements RequestHeaders {

    @Nullable
    private HttpMethod method;
    @Nullable
    private URI uri;
    @Nullable
    private List acceptLanguages;
    @Nullable
    private Cookies cookies;

    DefaultRequestHeaders(HttpHeadersBase headers) {
        super(headers);
    }

    DefaultRequestHeaders(HttpHeaderGetters headers) {
        super(headers);
    }

    @Override
    public URI uri() {
        final URI uri = this.uri;
        if (uri != null) {
            return uri;
        }

        return this.uri = super.uri();
    }

    @Nullable
    @Override
    public Locale selectLocale(Iterable supportedLocales) {
        return super.selectLocale(supportedLocales);
    }

    @Override
    @Nullable
    public List acceptLanguages() {
        final List acceptLanguages = this.acceptLanguages;
        if (acceptLanguages != null) {
            return acceptLanguages;
        }

        return this.acceptLanguages = super.acceptLanguages();
    }

    @Override
    public HttpMethod method() {
        final HttpMethod method = this.method;
        if (method != null) {
            return method;
        }

        return this.method = super.method();
    }

    @Override
    public String path() {
        return super.path();
    }

    @Nullable
    @Override
    public String scheme() {
        return super.scheme();
    }

    @Nullable
    @Override
    public String authority() {
        return super.authority();
    }

    @Override
    public Cookies cookies() {
        final Cookies cookies = this.cookies;
        if (cookies != null) {
            return cookies;
        }
        return this.cookies = cookie();
    }

    @Override
    public RequestHeadersBuilder toBuilder() {
        return new DefaultRequestHeadersBuilder(this);
    }

    @Override
    public boolean equals(@Nullable Object o) {
        return o instanceof RequestHeaders && super.equals(o);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy