ratpack.http.Request.getBodyStream() implementation

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

ratpack.http.Request.getBodyStream() implementation

Md Zahid Raza
ratpack.http.Request.getBodyStream() returns TransformablePublisher<? extends ByteBuf> which by default publishes/emits 8192 bytes of request body when requested by Subscriber using Subcription.request(1).
My question is:
1. how can I configure the number of bytes emitted by publisher
2. Is it possible to override publisher's publish/emit logic. if yes,how? My request consist of array of json objects and I want to publish 1 json object on each request of subscriber
rus
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ratpack.http.Request.getBodyStream() implementation

rus
The bytes emitted by the publisher are defined by the http chunk size.  This is set to 8192 here https://github.com/ratpack/ratpack/blob/1041ed6f9caa2d0d2468a8e1dd0e6c4e4c2ee0c0/ratpack-core/src/main/java/ratpack/http/client/internal/RequestActionSupport.java#L197 and is not configurable I'm afraid.  I'm not sure the reason behind these defaults other than they are also the Netty defaults.  RequestConfig could be extended to allow you to override these.

For an example of overriding the emit logic I would look at our SSE support where we decode the stream of ByteBuf https://github.com/ratpack/ratpack/blob/1041ed6f9caa2d0d2468a8e1dd0e6c4e4c2ee0c0/ratpack-core/src/main/java/ratpack/sse/internal/DefaultServerSentEventStreamClient.java
Loading...