-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refine HttpChannel.Listener #9872
Merged
gregw
merged 4 commits into
fix/12.0.x/restore-httpchannel-listener
from
fix/12.0.x/restore-httpchannel-listener-alt
Jun 6, 2023
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -128,95 +128,116 @@ interface Factory | |
* <p>Listener instances that are set as a bean on the {@link Connector} are | ||
* efficiently added to {@link HttpChannel}. | ||
*/ | ||
public interface Listener extends EventListener | ||
interface Listener extends EventListener | ||
{ | ||
/** | ||
* Invoked just after the HTTP request line and headers have been parsed. | ||
* Invoked just after the HTTP request line and headers have been parsed | ||
* (i.e. from within the call to {@link HttpChannel#onRequest(MetaData.Request)}). | ||
* | ||
* <p> | ||
* This the state of the request from the network, and does not include | ||
* any request customizations (eg: forwarding, secure, etc) | ||
* </p> | ||
* | ||
* <p> | ||
* Implementations must not block! | ||
* </p> | ||
* | ||
* @param request the request object | ||
* @param request the request object. The {@code read()} and {@code demand(Runnable)} methods must not be called by the listener. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think calling |
||
* @see HttpChannel#onRequest(MetaData.Request) | ||
*/ | ||
default void onRequestBegin(Request request) | ||
{ | ||
} | ||
|
||
/** | ||
* Invoked just before calling the server handler tree. | ||
* Invoked just before calling the server handler tree (i.e. just before the {@link Runnable} | ||
* returned from {@link HttpChannel#onRequest(MetaData.Request)} is run). | ||
* | ||
* <p> | ||
* This is the final state of the request before the handlers are called. | ||
* This includes any request customization. | ||
* </p> | ||
* | ||
* @param request the request object | ||
* @param request the request object. The {@code read()} and {@code demand(Runnable)} methods must not be called by the listener. | ||
* @see HttpChannel#onRequest(MetaData.Request) | ||
*/ | ||
default void onBeforeHandling(Request request) | ||
{ | ||
} | ||
|
||
/** | ||
* Invoked after application handling | ||
* Invoked after application handling (i.e. just after the call to the {@link Runnable} returned from | ||
* {@link HttpChannel#onRequest(MetaData.Request)} returns). | ||
* | ||
* @param request the request object | ||
* @param request the request object. The {@code read()} and {@code demand(Runnable)} methods must not be called by the listener. | ||
* @param handled if the server handlers handled the request | ||
* @param failure the exception thrown by the application | ||
* @see Handler#handle(Request, Response, Callback) | ||
* @see HttpChannel#onRequest(MetaData.Request) | ||
*/ | ||
default void onAfterHandling(Request request, boolean handled, Throwable failure) | ||
{ | ||
} | ||
|
||
/** | ||
* Invoked every time a request content chunk has been parsed, just before | ||
* making it available to the application. | ||
* | ||
* <p> | ||
* TODO: make notes about Trailers / EOF / Errors | ||
* </p> | ||
* making it available to the application (i.e. from within a call to | ||
* {@link Request#read()}). | ||
* | ||
* @param request the request object | ||
* @param chunk a request content chunk TODO: make bytebuffer a slice? | ||
* @param request the request object. The {@code read()} and {@code demand(Runnable)} methods must not be called by the listener. | ||
* @param chunk a request content chunk, including {@link org.eclipse.jetty.io.Content.Chunk.Error} | ||
* and {@link org.eclipse.jetty.http.Trailers} chunks. | ||
* If a reference to the chunk (or its {@link ByteBuffer}) is kept, | ||
* then {@link Content.Chunk#retain()} must be called. | ||
* @see Request#read() | ||
*/ | ||
default void onRequestRead(Request request, Content.Chunk chunk) | ||
{ | ||
} | ||
|
||
/** | ||
* Invoked just before the response line is written to the network. | ||
* Invoked just before the response is line written to the network (i.e. from | ||
* within the first call to {@link Response#write(boolean, ByteBuffer, Callback)}). | ||
* | ||
* @param request the request object | ||
* @param request the request object. The {@code read()} and {@code demand(Runnable)} methods must not be called by the listener. | ||
* @param status the response status | ||
* @param response the response object | ||
* @param response the immutable fields of the response object | ||
* @see Response#write(boolean, ByteBuffer, Callback) | ||
*/ | ||
default void onResponseCommitted(Request request, int status, HttpFields response) | ||
{ | ||
} | ||
|
||
/** | ||
* Invoked after a response content chunk has been written to the network. | ||
* Invoked before each response content chunk has been written (i.e. from | ||
* within the any call to {@link Response#write(boolean, ByteBuffer, Callback)}). | ||
* | ||
* @param request the request object | ||
* @param request the request object. The {@code read()} and {@code demand(Runnable)} methods must not be called by the listener. | ||
* @param last indicating last write | ||
* @param content a {@link ByteBuffer#slice() slice} of the response content chunk | ||
* @param content The {@link ByteBuffer} of the response content chunk (readonly). | ||
* @see Response#write(boolean, ByteBuffer, Callback) | ||
*/ | ||
default void onResponseWrite(Request request, boolean last, ByteBuffer content) | ||
{ | ||
} | ||
|
||
/** | ||
* Invoked after each response content chunk has been written | ||
* (i.e. immediately before calling the {@link Callback} passed to | ||
* {@link Response#write(boolean, ByteBuffer, Callback)}). | ||
* | ||
* @param request the request object. The {@code read()} and {@code demand(Runnable)} methods must not be called by the listener. | ||
* @param failure if there was a failure to write the given content | ||
* @see Response#write(boolean, ByteBuffer, Callback) | ||
*/ | ||
default void onResponseWrite(Request request, boolean last, ByteBuffer content, Throwable failure) | ||
default void onResponseWriteComplete(Request request, Throwable failure) | ||
{ | ||
} | ||
|
||
/** | ||
* Invoked when the request <em>and</em> response processing are complete, | ||
* just before the request and response will be recycled. | ||
* just before the request and response will be recycled (i.e. after the | ||
* {@link Runnable} return from {@link HttpChannel#onRequest(MetaData.Request)} | ||
* has returned and the {@link Callback} passed to {@link Handler#handle(Request, Response, Callback)} | ||
* has been completed). | ||
* | ||
* @param request the request object | ||
* @param request the request object. The {@code read()} and {@code demand(Runnable)} methods must not be called by the listener. | ||
* @param failure if there was a failure to complete | ||
*/ | ||
default void onComplete(Request request, Throwable failure) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrap with
<p>
.