Package io.grpc.servlet.jakarta.web
Class GrpcWebOutputStream
java.lang.Object
java.io.OutputStream
jakarta.servlet.ServletOutputStream
io.grpc.servlet.jakarta.web.GrpcWebOutputStream
- All Implemented Interfaces:
jakarta.servlet.WriteListener
,Closeable
,Flushable
,AutoCloseable
,EventListener
public class GrpcWebOutputStream
extends jakarta.servlet.ServletOutputStream
implements jakarta.servlet.WriteListener
Wraps the usual ServletOutputStream so as to allow downstream writers to use it according to the servlet spec, but
still make it easy to write trailers as a payload instead of using HTTP trailers at the end of a stream.
-
Constructor Summary
ConstructorDescriptionGrpcWebOutputStream
(jakarta.servlet.ServletOutputStream wrapped, GrpcWebServletResponse grpcWebServletResponse) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
void
flush()
boolean
isReady()
void
void
void
setWriteListener
(jakarta.servlet.WriteListener writeListener) void
write
(byte[] b) void
write
(byte[] b, int off, int len) void
write
(int i) void
writeAndCloseWhenReady
(byte[] bytes, Runnable close) Internal helper method to correctly write the given bytes, then complete the stream.Methods inherited from class jakarta.servlet.ServletOutputStream
print, print, print, print, print, print, print, println, println, println, println, println, println, println, println
Methods inherited from class java.io.OutputStream
nullOutputStream
-
Constructor Details
-
GrpcWebOutputStream
public GrpcWebOutputStream(jakarta.servlet.ServletOutputStream wrapped, GrpcWebServletResponse grpcWebServletResponse)
-
-
Method Details
-
isReady
public boolean isReady()- Specified by:
isReady
in classjakarta.servlet.ServletOutputStream
-
writeAndCloseWhenReady
Internal helper method to correctly write the given bytes, then complete the stream.- Parameters:
bytes
- the bytes to write once writing is possibleclose
- a Runnable to invoke once this write is complete
-
setWriteListener
public void setWriteListener(jakarta.servlet.WriteListener writeListener) - Specified by:
setWriteListener
in classjakarta.servlet.ServletOutputStream
-
write
- Specified by:
write
in classOutputStream
- Throws:
IOException
-
write
- Overrides:
write
in classOutputStream
- Throws:
IOException
-
write
- Overrides:
write
in classOutputStream
- Throws:
IOException
-
flush
- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classOutputStream
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
- Throws:
IOException
-
onWritePossible
- Specified by:
onWritePossible
in interfacejakarta.servlet.WriteListener
- Throws:
IOException
-
onError
- Specified by:
onError
in interfacejakarta.servlet.WriteListener
-