-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Support Publisher<ByteBuffer>in RESTEasy reactive #33130
Comments
/cc @FroMage (resteasy-reactive), @Sgitario (resteasy-reactive), @geoand (resteasy-reactive), @stuartwdouglas (resteasy-reactive) |
Actually, it will be very hard to make |
But I do I need to think of how we can address the general idea of what is being attempted here - which is to to support streaming data but also setting headers |
@FroMage @cescoffier what if we introduce some kind of custom |
Yes, we can try this. If you implement Publisher, Mutiny will consider you unsafe and may introduce additional checks. If you extend AbstractMulti we can avoid these checks (but you must make sure your code is correct) |
#33197 is what I have in mind. We still need to see about supporting |
@geoand Thanks, got it working with
Regarding ByteBuffer, I don't know if there is a better way to avoid copying the backed array of bytes back and forth. |
Spoke a bit fast, actually custom headers are not produced in my case |
Yeah, you need my PR for that |
I'm testing with it (I believe I do at least :)). |
See the tests for it's used |
I see the tests but headers are hard coded and they will usually come from a call to something else, thus from a Uni or something alike. I also tried to do it without |
In your case the header just comes from a method parameter, correct? That should just work |
RestMulti needs to be the return type, you can't mix it with Uni |
No, I make a call to an external reactive service. The uni response provides both some headers and a Publisher of byte. It's like having a resteasy client with a method return a Quick pseudo code @Path("/proxy")
public interface ProxyClient {
Uni<Response> proxy();
}
ProxyClient proxy;
@Path("/test")
public Multi<Buffer> test() {
// this doesn't work and I don't know how to wire things up to make it works
return proxy.proxy().onItem().transformToMulti(response -> RestMulti.from(response.getPublisher())
.header("Content-Lengnth", response.getLength())
.header("x-custom-1", response.getHeaderString("z-custom-2")));
}
@Path("/proxy")
public RestMulti<String> proxy() {
// this should work as expected with the PR
return RestMulti.from(Multi.createFrom().items("foo", "bar")).header("z-custom-2", "banana").build();
} |
Gotcha, thanks |
I'll have a look tomorrow at how something like that can be done. |
This request actually becomes very problematic in light of: #22762 - i.e. when returning SSE events we need to return the initial HTTP frame ASAP, we can't wait for the actual response. So I am wondering if we should limit the feature to non-SSE streamed responses... |
I have pushed a second commit which addresses your use case |
That's what I thought at first. I was thinking of a dedicated server message serializer but I struggle to wire up the multi with the resteasy server response object. Trying to make things like the asyncfile support. Will look at your second commit soon |
Introduce a way to set headers and status code for streaming response
Description
I would like to be able to pipe a
Publisher<ByteBuffer>
into aRestResponse
.Given a
Uni<Publisher<ByteBuffer>>
, I would like to be able to doI tried to produce
Multi<byte[]>
withbut got an exception :
Implementation ideas
No response
The text was updated successfully, but these errors were encountered: