-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Fixes #13098 - HTTP2 Server Error Handling is different than HTTP1 #13141
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
Fixes #13098 - HTTP2 Server Error Handling is different than HTTP1 #13141
Conversation
TODO: * Restore use of HttpURI.build() in HttpSenderOverHTTP2. * Use HttpURI.Unsafe to write a test case. * HttpURI.Unsafe javadocs. Signed-off-by: Simone Bordet <[email protected]>
Signed-off-by: Simone Bordet <[email protected]>
Signed-off-by: Simone Bordet <[email protected]>
Signed-off-by: Simone Bordet <[email protected]>
Signed-off-by: Simone Bordet <[email protected]>
@lorban will h3 need similar changes? |
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.
CI is badly broken as well.
@@ -135,4 +139,68 @@ public MetaData parse(ByteBuffer buffer, int blockLength) | |||
} | |||
} | |||
} | |||
|
|||
public static class SessionFailureMetaData extends MetaData |
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.
javadoc
} | ||
} | ||
|
||
public interface StreamFailureMetaData |
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.
javadoc
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.
Why is both a session and stream failure needed? Can't a session failure be detected by the fact that it has a failed stream?
Or perhaps it could just be a FailureMetaData with reason in the getFailure?
...http2/jetty-http2-common/src/main/java/org/eclipse/jetty/http2/parser/HeaderBlockParser.java
Outdated
Show resolved
Hide resolved
@gregw yes, H3 probably suffers from the same problem. |
Signed-off-by: Simone Bordet <[email protected]>
...etty-http3/jetty-http3-qpack/src/main/java/org/eclipse/jetty/http3/qpack/QpackException.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/HttpURI.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Simone Bordet <[email protected]>
Signed-off-by: Simone Bordet <[email protected]>
Signed-off-by: Simone Bordet <[email protected]>
Signed-off-by: Simone Bordet <[email protected]>
* Fixed HTTP2Stream.reset() logic. Signed-off-by: Simone Bordet <[email protected]>
@@ -506,6 +507,27 @@ public String toString() | |||
} | |||
} | |||
|
|||
/** | |||
* <p>An unsafe {@link HttpURI} that accepts URI parts without checking whether they are valid.</p> |
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.
* <p>An unsafe {@link HttpURI} that accepts URI parts without checking whether they are valid.</p> | |
* <p>An unsafe {@link HttpURI} that accepts URI parts without checking whether they are valid. | |
* Primarily intended for testing, as un-validated may break arbitrary code.</p> |
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.
It's also used by Jetty HttpClient to allow it to make requests that other servers would allow, but we don't.
An example would be using the %00
in the request path.
In jetty-12.0.x HEAD our HttpURI and MetaData classes both reject that pct-encoding, but it's 100% allowed to be sent from a user-agent.
jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/MetaData.java
Show resolved
Hide resolved
.scheme(_scheme) | ||
.host(_authority == null ? null : _authority.getHost()) | ||
.port(_authority == null ? -1 : _authority.getPort()) | ||
.pathQuery(_path); |
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.
Do we need?
.pathQuery(_path); | |
.pathQuery(_path) | |
.asImmutable(); |
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.
It creates another object in the hot path, and the return type is already just HttpURI
, not its Mutable
subclass.
jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/MetaData.java
Outdated
Show resolved
Hide resolved
private final boolean request; | ||
private final boolean response; | ||
|
||
public StreamException(boolean request, boolean response, String messageFormat, Object... args) |
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.
Why are these exceptions taking format + args instead of a pre-formatted string?
...-http2-server/src/main/java/org/eclipse/jetty/http2/server/internal/HttpStreamOverHTTP2.java
Outdated
Show resolved
Hide resolved
.path(path) | ||
.query(request.getQuery()); | ||
// URI validations already performed by using the java.net.URI class. | ||
HttpURI uri = new HttpURI.Unsafe(request.getScheme(), request.getHost(), request.getPort(), path, request.getQuery(), null); |
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.
A side-effect of this change makes the HttpURI
immutable.
I wonder if the MetaData.Request
constructors shouldn't always call immutable()
on the HttpURI
parameter they are given?
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.
It would be another allocation in the hot path, and the signature returns the immutable HttpURI
type.
.scheme(_scheme) | ||
.host(_authority == null ? null : _authority.getHost()) | ||
.port(_authority == null ? -1 : _authority.getPort()) | ||
.pathQuery(_path); |
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.
immutable()
?
Signed-off-by: Simone Bordet <[email protected]>
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.
There is still the oddity of StreamException
and HpackException
taking format + args, otherwise LGTM.
Can this be merged ? |
Errors happening before the request is handled are now handled similarly to HTTP/1.1, and are now hitting the
ErrorHandler
, so that a 400 response can be generated.