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

org.eclipse.jetty.spdy.api.HeadersInfo Maven / Gradle / Ivy

There is a newer version: 11.0.0.beta1
Show newest version
//
//  ========================================================================
//  Copyright (c) 1995-2018 Mort Bay Consulting Pty. Ltd.
//  ------------------------------------------------------------------------
//  All rights reserved. This program and the accompanying materials
//  are made available under the terms of the Eclipse Public License v1.0
//  and Apache License v2.0 which accompanies this distribution.
//
//      The Eclipse Public License is available at
//      http://www.eclipse.org/legal/epl-v10.html
//
//      The Apache License v2.0 is available at
//      http://www.opensource.org/licenses/apache2.0.php
//
//  You may elect to redistribute this code under either of these licenses.
//  ========================================================================
//

package org.eclipse.jetty.spdy.api;

import java.util.concurrent.TimeUnit;

import org.eclipse.jetty.util.Fields;

/**
 * 

A container for HEADERS frame metadata and headers.

*/ public class HeadersInfo extends Info { /** *

Flag that indicates that this {@link HeadersInfo} is the last frame in the stream.

* * @see #isClose() * @see #getFlags() */ public static final byte FLAG_CLOSE = 1; /** *

Flag that indicates that the compression of the stream must be reset.

* * @see #isResetCompression() * @see #getFlags() */ public static final byte FLAG_RESET_COMPRESSION = 2; private final boolean close; private final boolean resetCompression; private final Fields headers; /** *

Creates a new {@link HeadersInfo} instance with the given headers, the given close flag and no reset * compression flag

* * @param headers the {@link Fields} * @param close the value of the close flag */ public HeadersInfo(Fields headers, boolean close) { this(headers, close, false); } /** *

Creates a new {@link HeadersInfo} instance with the given headers, the given close flag and the given reset * compression flag

* * @param headers the {@link Fields} * @param close the value of the close flag * @param resetCompression the value of the reset compression flag */ public HeadersInfo(Fields headers, boolean close, boolean resetCompression) { this.headers = headers; this.close = close; this.resetCompression = resetCompression; } /** *

Creates a new {@link HeadersInfo} instance with the given headers, the given close flag and the given reset * compression flag

* * @param timeout the operation's timeout * @param unit the timeout's unit * @param headers the {@link Fields} * @param close the value of the close flag * @param resetCompression the value of the reset compression flag */ public HeadersInfo(long timeout, TimeUnit unit, boolean close, boolean resetCompression, Fields headers) { super(timeout, unit); this.close = close; this.resetCompression = resetCompression; this.headers = headers; } /** * @return the value of the close flag */ public boolean isClose() { return close; } /** * @return the value of the reset compression flag */ public boolean isResetCompression() { return resetCompression; } /** * @return the {@link Fields} */ public Fields getHeaders() { return headers; } /** * @return the close and reset compression flags as integer * @see #FLAG_CLOSE * @see #FLAG_RESET_COMPRESSION */ public byte getFlags() { byte flags = isClose() ? FLAG_CLOSE : 0; flags += isResetCompression() ? FLAG_RESET_COMPRESSION : 0; return flags; } @Override public String toString() { return String.format("HEADER close=%b %s", close, headers); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy