Search in sources :

Example 1 with VERSION

use of io.aklivity.zilla.runtime.binding.http.internal.types.ProxySecureInfoType.VERSION in project zilla by aklivity.

the class HttpServerFactory method decodeStartLine.

private DirectBuffer decodeStartLine(DirectBuffer buffer, int offset, int limit, HttpBeginExFW.Builder httpBeginEx, MutableBoolean hasAuthority, String16FW scheme) {
    DirectBuffer error = null;
    final CharSequence startLine = new AsciiSequenceView(buffer, offset, limit - offset);
    if (startLine.length() >= maximumHeadersSize) {
        error = ERROR_414_REQUEST_URI_TOO_LONG;
    } else if (requestLine.reset(startLine).matches()) {
        final String method = requestLine.group("method");
        final String target = requestLine.group("target");
        final String version = requestLine.group("version");
        final URI targetURI = createTargetURI(target);
        if (targetURI == null) {
            error = ERROR_400_BAD_REQUEST;
        } else if (!versionPart.reset(version).matches()) {
            error = ERROR_505_VERSION_NOT_SUPPORTED;
        } else if (targetURI.getUserInfo() != null) {
            error = ERROR_400_BAD_REQUEST;
        } else if (!SUPPORTED_METHODS.contains(method)) {
            error = ERROR_501_METHOD_NOT_IMPLEMENTED;
        } else {
            final String path = targetURI.getRawPath();
            final String authority = targetURI.getAuthority();
            httpBeginEx.headersItem(h -> h.name(HEADER_SCHEME).value(scheme)).headersItem(h -> h.name(HEADER_METHOD).value(method)).headersItem(h -> h.name(HEADER_PATH).value(path));
            if (authority != null) {
                httpBeginEx.headersItem(h -> h.name(HEADER_AUTHORITY).value(authority));
                hasAuthority.value = true;
            }
        }
    } else {
        error = ERROR_400_BAD_REQUEST;
    }
    return error;
}
Also used : MutableDirectBuffer(org.agrona.MutableDirectBuffer) DirectBuffer(org.agrona.DirectBuffer) HttpPolicyConfig(io.aklivity.zilla.runtime.binding.http.internal.config.HttpAccessControlConfig.HttpPolicyConfig) NO_DEBITOR_INDEX(io.aklivity.zilla.runtime.engine.budget.BudgetDebitor.NO_DEBITOR_INDEX) HpackHeaderFieldFW(io.aklivity.zilla.runtime.binding.http.internal.hpack.HpackHeaderFieldFW) HpackStringFW(io.aklivity.zilla.runtime.binding.http.internal.hpack.HpackStringFW) LongSupplier(java.util.function.LongSupplier) BindingHandler(io.aklivity.zilla.runtime.engine.binding.BindingHandler) MessageConsumer(io.aklivity.zilla.runtime.engine.binding.function.MessageConsumer) UnsafeBuffer(org.agrona.concurrent.UnsafeBuffer) INCREMENTAL_INDEXING(io.aklivity.zilla.runtime.binding.http.internal.hpack.HpackLiteralHeaderFieldFW.LiteralType.INCREMENTAL_INDEXING) Http2SettingsFW(io.aklivity.zilla.runtime.binding.http.internal.codec.Http2SettingsFW) Matcher(java.util.regex.Matcher) Arrays.asList(java.util.Arrays.asList) HttpBinding(io.aklivity.zilla.runtime.binding.http.internal.HttpBinding) Http2ErrorCode(io.aklivity.zilla.runtime.binding.http.internal.codec.Http2ErrorCode) Map(java.util.Map) Http2PingFW(io.aklivity.zilla.runtime.binding.http.internal.codec.Http2PingFW) Array32FW(io.aklivity.zilla.runtime.binding.http.internal.types.Array32FW) UNKNOWN(io.aklivity.zilla.runtime.binding.http.internal.hpack.HpackHeaderFieldFW.HeaderFieldType.UNKNOWN) ProxyInfoFW(io.aklivity.zilla.runtime.binding.http.internal.types.ProxyInfoFW) WindowFW(io.aklivity.zilla.runtime.binding.http.internal.types.stream.WindowFW) EngineContext(io.aklivity.zilla.runtime.engine.EngineContext) BufferPool(io.aklivity.zilla.runtime.engine.buffer.BufferPool) EnumMap(java.util.EnumMap) PROXY_CONNECTION(io.aklivity.zilla.runtime.binding.http.internal.hpack.HpackContext.PROXY_CONNECTION) Http2DataFW(io.aklivity.zilla.runtime.binding.http.internal.codec.Http2DataFW) Set(java.util.Set) Signaler(io.aklivity.zilla.runtime.engine.concurrent.Signaler) EndFW(io.aklivity.zilla.runtime.binding.http.internal.types.stream.EndFW) BindingConfig(io.aklivity.zilla.runtime.engine.config.BindingConfig) BufferUtil.limitOfBytes(io.aklivity.zilla.runtime.binding.http.internal.util.BufferUtil.limitOfBytes) CONNECTION(io.aklivity.zilla.runtime.binding.http.internal.hpack.HpackContext.CONNECTION) Http2ContinuationFW(io.aklivity.zilla.runtime.binding.http.internal.codec.Http2ContinuationFW) AsciiSequenceView(org.agrona.AsciiSequenceView) HttpDataExFW(io.aklivity.zilla.runtime.binding.http.internal.types.stream.HttpDataExFW) LongLongConsumer(org.agrona.collections.LongLongConsumer) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) Long2ObjectHashMap(org.agrona.collections.Long2ObjectHashMap) MutableReference(org.agrona.collections.MutableReference) BiConsumer(java.util.function.BiConsumer) MutableInteger(org.agrona.collections.MutableInteger) MutableBoolean(org.agrona.collections.MutableBoolean) VERSION(io.aklivity.zilla.runtime.binding.http.internal.types.ProxySecureInfoType.VERSION) HttpEndExFW(io.aklivity.zilla.runtime.binding.http.internal.types.stream.HttpEndExFW) String16FW(io.aklivity.zilla.runtime.binding.http.internal.types.String16FW) KEEP_ALIVE(io.aklivity.zilla.runtime.binding.http.internal.hpack.HpackContext.KEEP_ALIVE) UPGRADE(io.aklivity.zilla.runtime.binding.http.internal.hpack.HpackContext.UPGRADE) ALPN(io.aklivity.zilla.runtime.binding.http.internal.types.ProxyInfoType.ALPN) HpackHuffman(io.aklivity.zilla.runtime.binding.http.internal.hpack.HpackHuffman) LongUnaryOperator(java.util.function.LongUnaryOperator) Http2PriorityFW(io.aklivity.zilla.runtime.binding.http.internal.codec.Http2PriorityFW) AtomicBuffer(org.agrona.concurrent.AtomicBuffer) BufferUtil.indexOfByte(io.aklivity.zilla.runtime.binding.http.internal.util.BufferUtil.indexOfByte) Http2PushPromiseFW(io.aklivity.zilla.runtime.binding.http.internal.codec.Http2PushPromiseFW) SortedSet(java.util.SortedSet) Http2Setting(io.aklivity.zilla.runtime.binding.http.internal.codec.Http2Setting) BudgetCreditor(io.aklivity.zilla.runtime.engine.budget.BudgetCreditor) WITHOUT_INDEXING(io.aklivity.zilla.runtime.binding.http.internal.hpack.HpackLiteralHeaderFieldFW.LiteralType.WITHOUT_INDEXING) SECURE(io.aklivity.zilla.runtime.binding.http.internal.types.ProxyInfoType.SECURE) LongHashSet(org.agrona.collections.LongHashSet) OctetsFW(io.aklivity.zilla.runtime.binding.http.internal.types.OctetsFW) Flyweight(io.aklivity.zilla.runtime.binding.http.internal.types.Flyweight) URI(java.net.URI) Http2WindowUpdateFW(io.aklivity.zilla.runtime.binding.http.internal.codec.Http2WindowUpdateFW) HttpBindingConfig(io.aklivity.zilla.runtime.binding.http.internal.config.HttpBindingConfig) HttpRouteConfig(io.aklivity.zilla.runtime.binding.http.internal.config.HttpRouteConfig) TRAILERS(io.aklivity.zilla.runtime.binding.http.internal.hpack.HpackContext.TRAILERS) Http2FrameType(io.aklivity.zilla.runtime.binding.http.internal.codec.Http2FrameType) Int2ObjectHashMap(org.agrona.collections.Int2ObjectHashMap) SignalFW(io.aklivity.zilla.runtime.binding.http.internal.types.stream.SignalFW) ExpandableArrayBuffer(org.agrona.ExpandableArrayBuffer) Instant(java.time.Instant) Objects(java.util.Objects) FlushFW(io.aklivity.zilla.runtime.binding.http.internal.types.stream.FlushFW) List(java.util.List) HttpBeginExFW(io.aklivity.zilla.runtime.binding.http.internal.types.stream.HttpBeginExFW) HpackContext(io.aklivity.zilla.runtime.binding.http.internal.hpack.HpackContext) MutableDirectBuffer(org.agrona.MutableDirectBuffer) Pattern(java.util.regex.Pattern) DirectBuffer(org.agrona.DirectBuffer) HttpConfiguration(io.aklivity.zilla.runtime.binding.http.internal.HttpConfiguration) Http2PrefaceFW(io.aklivity.zilla.runtime.binding.http.internal.codec.Http2PrefaceFW) HashMap(java.util.HashMap) BeginFW(io.aklivity.zilla.runtime.binding.http.internal.types.stream.BeginFW) HpackHeaderBlockFW(io.aklivity.zilla.runtime.binding.http.internal.hpack.HpackHeaderBlockFW) HttpAccessControlConfig(io.aklivity.zilla.runtime.binding.http.internal.config.HttpAccessControlConfig) HashSet(java.util.HashSet) DataFW(io.aklivity.zilla.runtime.binding.http.internal.types.stream.DataFW) HttpUtil(io.aklivity.zilla.runtime.binding.http.internal.util.HttpUtil) Http2GoawayFW(io.aklivity.zilla.runtime.binding.http.internal.codec.Http2GoawayFW) HpackLiteralHeaderFieldFW(io.aklivity.zilla.runtime.binding.http.internal.hpack.HpackLiteralHeaderFieldFW) TE(io.aklivity.zilla.runtime.binding.http.internal.hpack.HpackContext.TE) String8FW(io.aklivity.zilla.runtime.binding.http.internal.types.String8FW) ProxyBeginExFW(io.aklivity.zilla.runtime.binding.http.internal.types.stream.ProxyBeginExFW) NO_CREDITOR_INDEX(io.aklivity.zilla.runtime.engine.budget.BudgetCreditor.NO_CREDITOR_INDEX) Character.toUpperCase(java.lang.Character.toUpperCase) Http2HeadersFW(io.aklivity.zilla.runtime.binding.http.internal.codec.Http2HeadersFW) Iterator(java.util.Iterator) LongFunction(java.util.function.LongFunction) Http2FrameInfoFW(io.aklivity.zilla.runtime.binding.http.internal.codec.Http2FrameInfoFW) HttpVersion(io.aklivity.zilla.runtime.binding.http.internal.config.HttpVersion) UTF_8(java.nio.charset.StandardCharsets.UTF_8) AbortFW(io.aklivity.zilla.runtime.binding.http.internal.types.stream.AbortFW) HttpHeaderFW(io.aklivity.zilla.runtime.binding.http.internal.types.HttpHeaderFW) BudgetDebitor(io.aklivity.zilla.runtime.engine.budget.BudgetDebitor) Integer.parseInt(java.lang.Integer.parseInt) US_ASCII(java.nio.charset.StandardCharsets.US_ASCII) Consumer(java.util.function.Consumer) Http2RstStreamFW(io.aklivity.zilla.runtime.binding.http.internal.codec.Http2RstStreamFW) NO_SLOT(io.aklivity.zilla.runtime.engine.buffer.BufferPool.NO_SLOT) ResetFW(io.aklivity.zilla.runtime.binding.http.internal.types.stream.ResetFW) CROSS_ORIGIN(io.aklivity.zilla.runtime.binding.http.internal.config.HttpAccessControlConfig.HttpPolicyConfig.CROSS_ORIGIN) Character.toLowerCase(java.lang.Character.toLowerCase) URI(java.net.URI) AsciiSequenceView(org.agrona.AsciiSequenceView)

Aggregations

HttpBinding (io.aklivity.zilla.runtime.binding.http.internal.HttpBinding)1 HttpConfiguration (io.aklivity.zilla.runtime.binding.http.internal.HttpConfiguration)1 Http2ContinuationFW (io.aklivity.zilla.runtime.binding.http.internal.codec.Http2ContinuationFW)1 Http2DataFW (io.aklivity.zilla.runtime.binding.http.internal.codec.Http2DataFW)1 Http2ErrorCode (io.aklivity.zilla.runtime.binding.http.internal.codec.Http2ErrorCode)1 Http2FrameInfoFW (io.aklivity.zilla.runtime.binding.http.internal.codec.Http2FrameInfoFW)1 Http2FrameType (io.aklivity.zilla.runtime.binding.http.internal.codec.Http2FrameType)1 Http2GoawayFW (io.aklivity.zilla.runtime.binding.http.internal.codec.Http2GoawayFW)1 Http2HeadersFW (io.aklivity.zilla.runtime.binding.http.internal.codec.Http2HeadersFW)1 Http2PingFW (io.aklivity.zilla.runtime.binding.http.internal.codec.Http2PingFW)1 Http2PrefaceFW (io.aklivity.zilla.runtime.binding.http.internal.codec.Http2PrefaceFW)1 Http2PriorityFW (io.aklivity.zilla.runtime.binding.http.internal.codec.Http2PriorityFW)1 Http2PushPromiseFW (io.aklivity.zilla.runtime.binding.http.internal.codec.Http2PushPromiseFW)1 Http2RstStreamFW (io.aklivity.zilla.runtime.binding.http.internal.codec.Http2RstStreamFW)1 Http2Setting (io.aklivity.zilla.runtime.binding.http.internal.codec.Http2Setting)1 Http2SettingsFW (io.aklivity.zilla.runtime.binding.http.internal.codec.Http2SettingsFW)1 Http2WindowUpdateFW (io.aklivity.zilla.runtime.binding.http.internal.codec.Http2WindowUpdateFW)1 HttpAccessControlConfig (io.aklivity.zilla.runtime.binding.http.internal.config.HttpAccessControlConfig)1 HttpPolicyConfig (io.aklivity.zilla.runtime.binding.http.internal.config.HttpAccessControlConfig.HttpPolicyConfig)1 CROSS_ORIGIN (io.aklivity.zilla.runtime.binding.http.internal.config.HttpAccessControlConfig.HttpPolicyConfig.CROSS_ORIGIN)1