Skip to content
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

Issue #12266 - InvocationType improvements and cleanups. #12596

Open
wants to merge 22 commits into
base: jetty-12.1.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift click to select a range
1345a6f
Issue #12266 - InvocationType improvements and cleanups.
sbordet Nov 29, 2024
6ff2e58
Renamed HttpClient.getTransport() to getHttpClientTransport().
sbordet Nov 29, 2024
751c886
Fixed FCGI parsing: onResponseHeaders() was called multiple times in …
sbordet Nov 30, 2024
5352c05
Reverted theh renaming of `HttpClient.getTransport()`.
sbordet Dec 1, 2024
4d4c88a
Fixed race condition when notifying HTTP/2 `HeadersFrame`s.
sbordet Dec 2, 2024
a3b728e
Merged branch 'jetty-12.1.x' into 'fix/jetty-12.1.x/client-invocation…
sbordet Dec 2, 2024
fa7c4a4
Fixed IteratingCallback tests due to changes in toString().
sbordet Dec 2, 2024
78d8a66
Reverted "optimization" in `HttpReceiver.responseHeaders()`.
sbordet Dec 3, 2024
b0b60d1
Reverted another "optimization" in `HttpReceiver.responseHeaders()`.
sbordet Dec 3, 2024
3438462
Merged branch 'jetty-12.1.x' into 'fix/jetty-12.1.x/client-invocation…
sbordet Dec 8, 2024
f7788da
Merged branch 'jetty-12.1.x' into 'fix/jetty-12.1.x/client-invocation…
sbordet Dec 16, 2024
8e036dd
Merged branch 'jetty-12.1.x' into 'fix/jetty-12.1.x/client-invocation…
sbordet Dec 17, 2024
630d5c5
Fixed HTTP/2 serialization in HttpReceiverOverHTTP2.
sbordet Dec 20, 2024
7947030
Fixed tests.
sbordet Dec 20, 2024
dbc7da7
Fixed tests.
sbordet Dec 20, 2024
21d4dfc
Fixed tests.
sbordet Dec 23, 2024
2836d34
Merged branch 'jetty-12.1.x' into 'fix/jetty-12.1.x/client-invocation…
sbordet Dec 23, 2024
ae197ab
Fixed flaky tests.
sbordet Dec 24, 2024
d4da186
Fixed tests.
sbordet Dec 25, 2024
39d7823
Fixed tests.
sbordet Dec 26, 2024
6dbeb96
Fixed handling of HTTP upgrade in CoreClientUpgradeRequest.
sbordet Dec 26, 2024
57c3d95
Cleanups.
sbordet Dec 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixed handling of HTTP upgrade in CoreClientUpgradeRequest.
For HTTP/2, the response may have arrived, but the exchange failed (due to the request being failed); in this case, we want to notify an UpgradeException, not a generic Exception.

Signed-off-by: Simone Bordet <[email protected]>
  • Loading branch information
sbordet committed Dec 26, 2024
commit 6dbeb960fad2cee1ecc7c2570d4a9a044b08d394
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 35,6 @@
import org.eclipse.jetty.http.HttpFields;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpScheme;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.EndPoint;
Expand Down Expand Up @@ -249,43 248,37 @@ public void onComplete(Result result)
Response response = result.getResponse();
int status = response.getStatus();
String responseLine = status " " response.getReason();
boolean receivedResponse = status > 0;

if (result.isFailed())
if (receivedResponse)
{
if (upgraded)
return;

// We have failed to upgrade but have received a response, notify the listeners.
Throwable listenerError = notifyUpgradeListeners((listener) -> listener.onHandshakeResponse(request, response));
if (listenerError != null)
{
if (LOG.isDebugEnabled())
LOG.debug("Failure while notifying handshake response listeners", listenerError);
}
handleException(new UpgradeException(requestURI, status,
"Failed to upgrade to websocket: Unexpected HTTP Response Status Code: " responseLine));
}
else
{
if (LOG.isDebugEnabled())
{
if (result.getFailure() != null)
LOG.debug("General Failure", result.getFailure());
if (result.getRequestFailure() != null)
LOG.debug("Request Failure", result.getRequestFailure());
LOG.debug("Failed to upgrade to websocket: request failure", result.getRequestFailure());
if (result.getResponseFailure() != null)
LOG.debug("Response Failure", result.getResponseFailure());
LOG.debug("Failed to upgrade to websocket: response failure", result.getResponseFailure());
}

Throwable failure = result.getFailure();
boolean wrapFailure = !(failure instanceof IOException) && !(failure instanceof UpgradeException);
if (wrapFailure)
failure = new UpgradeException(requestURI, status, responseLine, failure);
handleException(failure);
return;
}

if (!upgraded)
{
// We have failed to upgrade but have received a response, so notify the listener.
Throwable listenerError = notifyUpgradeListeners((listener) -> listener.onHandshakeResponse(request, response));
if (listenerError != null)
{
if (LOG.isDebugEnabled())
LOG.debug("error from listener", listenerError);
}
}

if (status != HttpStatus.SWITCHING_PROTOCOLS_101)
{
// Failed to upgrade (other reason)
handleException(new UpgradeException(requestURI, status,
"Failed to upgrade to websocket: Unexpected HTTP Response Status Code: " responseLine));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,25 338,17 @@ public void onComplete(Result result)
@MethodSource("transportsNoFCGI")
public void testRedirectWithExpect100ContinueWithContent(TransportType transportType) throws Exception
{
// A request with Expect: 100-Continue cannot receive non-final responses like 3xx
// A request with Expect: 100-Continue cannot receive non-final responses like 3xx.

String data = "success";
start(transportType, new HttpServlet()
{
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException
{
if (request.getRequestURI().endsWith("/done"))
{
// Send 100-Continue and consume the content
IO.copy(request.getInputStream(), new ByteArrayOutputStream());
response.getOutputStream().print(data);
}
else
{
// Send a redirect
response.sendRedirect("/done");
}
throw new IOException("Redirect should not have been followed");
// Send a redirect.
response.sendRedirect("/done");
}
});

Expand All @@ -374,8 366,7 @@ public void onComplete(Result result)
{
assertTrue(result.isFailed());
assertNotNull(result.getRequestFailure());
assertNull(result.getResponseFailure());
assertEquals(302, result.getResponse().getStatus());
assertEquals(HttpStatus.MOVED_TEMPORARILY_302, result.getResponse().getStatus());
latch.countDown();
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,25 339,17 @@ public void onComplete(Result result)
@MethodSource("transportsNoFCGI")
public void testRedirectWithExpect100ContinueWithContent(TransportType transportType) throws Exception
{
// A request with Expect: 100-Continue cannot receive non-final responses like 3xx
// A request with Expect: 100-Continue cannot receive non-final responses like 3xx.

String data = "success";
start(transportType, new HttpServlet()
{
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException
{
if (request.getRequestURI().endsWith("/done"))
{
// Send 100-Continue and consume the content
IO.copy(request.getInputStream(), new ByteArrayOutputStream());
response.getOutputStream().print(data);
}
else
{
// Send a redirect
response.sendRedirect("/done");
}
throw new IOException("Redirect should not have been followed");
// Send a redirect.
response.sendRedirect("/done");
}
});

Expand All @@ -375,8 367,7 @@ public void onComplete(Result result)
{
assertTrue(result.isFailed());
assertNotNull(result.getRequestFailure());
assertNull(result.getResponseFailure());
assertEquals(302, result.getResponse().getStatus());
assertEquals(HttpStatus.MOVED_TEMPORARILY_302, result.getResponse().getStatus());
latch.countDown();
}
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 1,3 @@
# Jetty Logging using jetty-slf4j-impl
# org.eclipse.jetty.LEVEL=DEBUG
# org.eclipse.jetty.websocket.LEVEL=DEBUG
# org.eclipse.jetty.websocket.test.LEVEL=DEBUG
Expand Down
Loading