Package org.eclipse.jetty.ee9.nested
Interface HttpInput.Interceptor
- Enclosing class:
HttpInput
Deprecated, for removal: This API element is subject to removal in a future version.
Interceptor has been removed with no replacement in the EE10 implementation
HttpInput.Content
interceptor that can be registered using HttpInput.setInterceptor(Interceptor)
or
HttpInput.addInterceptor(Interceptor)
.
When HttpInput.Content
instances are generated, they are passed to the registered interceptor (if any)
that is then responsible for providing the actual content that is consumed by HttpInput.read(byte[], int, int)
and its
sibling methods.
public HttpInput.Content readFrom(HttpInput.Content content) { LOGGER.debug("read content: {}", asString(content)); return content; }which would not do anything with the content besides logging it. A more involved implementation could look like the following:
public HttpInput.Content readFrom(HttpInput.Content content) { if (content.hasContent()) this.processedContent = processContent(content.getByteBuffer()); if (content.isEof()) disposeResources(); return content.isSpecial() ? content : this.processedContent; }Implementors of this interface must keep the following in mind:
- Calling
HttpInput.Content.getByteBuffer()
whenHttpInput.Content.isSpecial()
returnstrue
throwsIllegalStateException
. - A
HttpInput.Content
can both be non-special and haveHttpInput.Content.isEof()
returntrue
. HttpInput.Content
extendsCallback
to manage the lifecycle of the contained byte buffer. The code callingreadFrom(Content)
is responsible for managing the lifecycle of both the passed and the returned content instances, onceBuffer.hasRemaining()
returnsfalse
HttpInput
will make sureCallback.succeeded()
is called, orCallback.failed(Throwable)
if an error occurs.- After
readFrom(Content)
is called for the first time, subsequentreadFrom(Content)
calls will occur only after the contained byte buffer is empty (see above) or at any time if the returned content was special. - Once
readFrom(Content)
returned a special content, subsequent calls toreadFrom(Content)
must always return the same special content. - Implementations implementing both this interface and
Destroyable
will have theirDestroyable.destroy()
method called whenHttpInput.recycle()
is called.
-
Method Summary
Modifier and TypeMethodDescriptionreadFrom
(HttpInput.Content content) Deprecated, for removal: This API element is subject to removal in a future version.
-
Method Details
-
readFrom
Deprecated, for removal: This API element is subject to removal in a future version.- Parameters:
content
- The content to be intercepted. The content will be modified with any data the interceptor consumes. There is no requirement that all the data is consumed by the interceptor but at least one byte must be consumed unless the returned content is the passed content instance.- Returns:
- The intercepted content or null if interception is completed for that content.
-