Class FrameLimitController
java.lang.Object
org.apache.hc.core5.http2.impl.nio.FrameLimitController
Per-connection resource policy for unsolicited HTTP/2 control frames. Non-ACK PING and
SETTINGS frames share one token bucket, exactly as before this class existed; rapid
cancellation (RST_STREAM) of peer-initiated streams is charged against its own,
independent bucket.
ACK frames, DATA and WINDOW_UPDATE are not charged, as they can represent legitimate high-throughput or highly concurrent exchanges. A stream reset is only charged against the RST_STREAM bucket when it arrives shortly after the stream was activated; resets of long-lived streams are not charged.
Parameters are hardwired for now; they may become user configurable in the future, at which point this is the single place that would need a public constructor or setters.
This is a resource safeguard, not an RFC 9113 protocol-validity rule.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final classConstant-time token bucket, with no locks or per-frame allocation, used to tolerate bursts and recover over time. -
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final int(package private) static final intprivate final FrameLimitController.TokenBucket(package private) static final int(package private) static final long(package private) static final intprivate final FrameLimitController.TokenBucketprivate final long -
Constructor Summary
ConstructorsConstructorDescriptionFrameLimitController(int controlFrameCapacity, int controlFrameRefillPerSecond, int rstStreamCapacity, int rstStreamRefillPerSecond, long rstStreamMaxAgeNanos) -
Method Summary
Modifier and TypeMethodDescription(package private) booleanacceptControlFrame(long nowNanos) (package private) booleanacceptRapidReset(long activatedAtNanos, long nowNanos)
-
Field Details
-
CONTROL_FRAME_CAPACITY
static final int CONTROL_FRAME_CAPACITY- See Also:
-
CONTROL_FRAME_REFILL_PER_SECOND
static final int CONTROL_FRAME_REFILL_PER_SECOND- See Also:
-
RST_STREAM_CAPACITY
static final int RST_STREAM_CAPACITY- See Also:
-
RST_STREAM_REFILL_PER_SECOND
static final int RST_STREAM_REFILL_PER_SECOND- See Also:
-
RST_STREAM_MAX_AGE_NANOS
static final long RST_STREAM_MAX_AGE_NANOS -
controlFrameBucket
-
rstStreamBucket
-
rstStreamMaxAgeNanos
private final long rstStreamMaxAgeNanos
-
-
Constructor Details
-
FrameLimitController
FrameLimitController() -
FrameLimitController
FrameLimitController(int controlFrameCapacity, int controlFrameRefillPerSecond, int rstStreamCapacity, int rstStreamRefillPerSecond, long rstStreamMaxAgeNanos)
-
-
Method Details
-
acceptControlFrame
boolean acceptControlFrame(long nowNanos) -
acceptRapidReset
boolean acceptRapidReset(long activatedAtNanos, long nowNanos)
-