Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (C) 2015-2018 SoftIndex LLC.
*
* Licensed 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
*
* http://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 io.datakernel.http;
import io.datakernel.bytebuf.ByteBuf;
import io.datakernel.bytebuf.ByteBufQueue;
import io.datakernel.common.MemSize;
import io.datakernel.common.Recyclable;
import io.datakernel.common.exception.UncheckedException;
import io.datakernel.common.parse.InvalidSizeException;
import io.datakernel.common.parse.ParseException;
import io.datakernel.common.parse.ParserFunction;
import io.datakernel.csp.ChannelSupplier;
import io.datakernel.csp.ChannelSuppliers;
import io.datakernel.http.HttpHeaderValue.ParserIntoList;
import io.datakernel.promise.Promise;
import org.intellij.lang.annotations.MagicConstant;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Type;
import java.util.*;
import static io.datakernel.bytebuf.ByteBufStrings.*;
import static io.datakernel.csp.ChannelConsumers.recycling;
import static java.util.Collections.emptySet;
/**
* Represents any HTTP message. Its internal byte buffers will be automatically recycled in HTTP client or HTTP server.
*/
@SuppressWarnings({"unused", "WeakerAccess", "PointlessBitwiseExpression"})
public abstract class HttpMessage {
/**
* This flag means that the body of this message should not be streamed
* and should be collected into a single body {@link ByteBuf}.
* This flag is removed when body is taken away or recycled.
*/
static final byte MUST_LOAD_BODY = 1 << 0;
/**
* This flag means that the DEFLATE compression algorithm will be used
* to compress/decompress the body of this message.
*/
static final byte USE_GZIP = 1 << 1;
/**
* This flag means that the body was already recycled and is not accessible.
* It is mostly used in assertions.
*/
static final byte RECYCLED = (byte) (1 << 7);
@MagicConstant(flags = {MUST_LOAD_BODY, USE_GZIP, RECYCLED})
byte flags;
final HttpHeadersMultimap headers = new HttpHeadersMultimap<>();
@Nullable ByteBuf body;
@Nullable ChannelSupplier bodyStream;
Recyclable bufs;
protected int maxBodySize;
protected Map