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

Refine how Request / Channel / Stream completion works #9684

Merged
merged 34 commits into from
May 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
406f74f
Restore LargeHeaderTest Test
joakime Apr 24, 2023
1939ee5
Correct HttpChannelState to satisfy HttpChannelTest failures
joakime Apr 28, 2023
194e85f
Merge remote-tracking branch 'origin/jetty-12.0.x' into fix/12.0.x/la…
joakime May 1, 2023
13f846f
Merge remote-tracking branch 'origin/jetty-12.0.x' into fix/12.0.x/la…
joakime May 2, 2023
969d772
Merge remote-tracking branch 'origin/jetty-12.0.x' into fix/12.0.x/la…
joakime May 2, 2023
2f16af7
Merge remote-tracking branch 'origin/jetty-12.0.x' into fix/12.0.x/la…
joakime May 3, 2023
287e351
More DEBUG + ignoring failure for completeStream
joakime May 4, 2023
e715dab
LargeHeaderTest WIP
joakime May 5, 2023
7b52b1e
Merge remote-tracking branch 'origin/jetty-12.0.x' into fix/12.0.x/la…
joakime May 5, 2023
d61bbf3
LargeHeaderTest WIP
joakime May 5, 2023
b569fad
LargeHeaderTest WIP
joakime May 5, 2023
42146ed
Added some javadoc, logging and better toString implementations to he…
gregw May 6, 2023
c3dd607
Simplified onFailure
gregw May 6, 2023
7c721d5
Merge remote-tracking branch 'origin/jetty-12.0.x' into fix/12.0.x/la…
gregw May 8, 2023
353133f
WIP
gregw May 9, 2023
9d8acf3
WIP
gregw May 9, 2023
cef9455
Getting better....
gregw May 9, 2023
702b8f1
Getting better....
gregw May 9, 2023
36e5aec
Getting better....
gregw May 9, 2023
d433b08
Hmmmmm
gregw May 9, 2023
31f9208
Working
gregw May 9, 2023
f323e97
Removed ErrorResponse in favour or an errorMode
gregw May 9, 2023
e48c8bc
made flaky test always fail
gregw May 10, 2023
d4b3082
made flaky test always fail more debugging
gregw May 10, 2023
7502618
Merge remote-tracking branch 'origin/jetty-12.0.x' into fix/12.0.x/la…
gregw May 10, 2023
5ad0572
Added a ServerTest with different completions
gregw May 10, 2023
edfdf67
Merge remote-tracking branch 'origin/jetty-12.0.x' into fix/12.0.x/la…
gregw May 10, 2023
16e11dc
Fixed tests
gregw May 10, 2023
df25af2
Fixed websocket flush
gregw May 10, 2023
60b3ea4
Fixed chunk close test
gregw May 10, 2023
b7b60a5
Fixed failing test StreamResetTest.testClientResetConsumesQueuedReque…
sbordet May 11, 2023
0be5943
updates from review
gregw May 14, 2023
8ad2ecc
Merge remote-tracking branch 'origin/jetty-12.0.x' into fix/12.0.x/la…
gregw May 14, 2023
55d3644
updates from review
gregw May 14, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package org.eclipse.jetty.http;

import java.nio.ByteBuffer;
import java.util.EnumSet;

import org.eclipse.jetty.util.Index;
import org.eclipse.jetty.util.StringUtil;
Expand Down Expand Up @@ -132,6 +133,18 @@ public enum HttpHeader
C_STATUS(":status", true),
C_PROTOCOL(":protocol");

public static final EnumSet<HttpHeader> CONTENT_HEADERS;
public static final EnumSet<HttpHeader> CONTENT_HEADERS_304;

static
{
CONTENT_HEADERS = EnumSet.of(
CONTENT_TYPE, CONTENT_LENGTH, CONTENT_ENCODING, CONTENT_LANGUAGE, CONTENT_RANGE, CONTENT_MD5, CONTENT_LOCATION, TRANSFER_ENCODING, CACHE_CONTROL, LAST_MODIFIED, EXPIRES, VARY, ETAG
);
CONTENT_HEADERS_304 = EnumSet.copyOf(CONTENT_HEADERS);
CONTENT_HEADERS_304.remove(ETAG);
}

sbordet marked this conversation as resolved.
Show resolved Hide resolved
public static final Index<HttpHeader> CACHE = new Index.Builder<HttpHeader>()
.caseSensitive(false)
.withAll(HttpHeader.values(), HttpHeader::toString)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ public void succeeded()
});

// Wait for WINDOW_UPDATEs to be processed by the client.
await().atMost(1000, TimeUnit.SECONDS).until(() -> ((HTTP2Session)client).updateSendWindow(0), Matchers.greaterThan(0));
await().atMost(5, TimeUnit.SECONDS).until(() -> ((HTTP2Session)client).updateSendWindow(0), Matchers.greaterThan(0));

latch.set(new CountDownLatch(2 * streams.size()));
// Notify all blocked threads to wakeup.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ default void push(MetaData.Request resource)
/**
* <p>Adds a listener for asynchronous errors.</p>
* <p>The listener is a predicate function that should return {@code true} to indicate
* that the function has completed (either successfully or with a failure) the callback
* that the function will complete (either successfully or with a failure) the callback
* received from {@link org.eclipse.jetty.server.Handler#handle(Request, Response, Callback)}, or
* {@code false} otherwise.</p>
* <p>Listeners are processed in sequence, and the first that returns {@code true}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.eclipse.jetty.http.QuotedQualityCSV;
import org.eclipse.jetty.io.ByteBufferOutputStream;
import org.eclipse.jetty.io.Content;
import org.eclipse.jetty.io.Retainable;
import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Response;
Expand Down Expand Up @@ -86,6 +87,8 @@ public boolean errorPageForMethod(String method)
@Override
public boolean handle(Request request, Response response, Callback callback)
{
if (LOG.isDebugEnabled())
LOG.debug("handle({}, {}, {})", request, response, callback);
if (_cacheControl != null)
response.getHeaders().put(_cacheControl);

Expand Down Expand Up @@ -256,22 +259,7 @@ else if (charsets.contains(StandardCharsets.ISO_8859_1))
}

response.getHeaders().put(type.getContentTypeField(charset));
response.write(true, buffer.getByteBuffer(), new Callback.Nested(callback)
{
@Override
public void succeeded()
{
buffer.release();
super.succeeded();
}

@Override
public void failed(Throwable x)
{
buffer.release();
super.failed(x);
}
});
response.write(true, buffer.getByteBuffer(), new WriteErrorCallback(callback, buffer));

return true;
}
Expand Down Expand Up @@ -576,5 +564,34 @@ public Set<String> getAttributeNameSet()
names.add(ERROR_EXCEPTION);
return names;
}

@Override
public String toString()
{
return "%s@%x:%s".formatted(getClass().getSimpleName(), hashCode(), getWrapped());
}
}

/**
* The callback used by
* {@link ErrorHandler#generateAcceptableResponse(Request, Response, Callback, String, List, int, String, Throwable)}
* when calling {@link Response#write(boolean, ByteBuffer, Callback)} to wrap the passed in {@link Callback}
* so that the {@link RetainableByteBuffer} used can be released.
*/
private static class WriteErrorCallback extends Callback.Nested
{
private final Retainable _retainable;

public WriteErrorCallback(Callback callback, Retainable retainable)
{
super(callback);
_retainable = retainable;
}

@Override
public void completed()
{
_retainable.release();
}
}
}
Loading