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
ConstructorsConstructorDescriptionGrpcWebOutputStream(jakarta.servlet.ServletOutputStream wrapped, GrpcWebServletResponse grpcWebServletResponse) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidflush()booleanisReady()voidvoidvoidsetWriteListener(jakarta.servlet.WriteListener writeListener) voidwrite(byte[] b) voidwrite(byte[] b, int off, int len) voidwrite(int i) voidwriteAndCloseWhenReady(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, printlnMethods 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:
isReadyin 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:
setWriteListenerin classjakarta.servlet.ServletOutputStream
-
write
- Specified by:
writein classOutputStream- Throws:
IOException
-
write
- Overrides:
writein classOutputStream- Throws:
IOException
-
write
- Overrides:
writein classOutputStream- Throws:
IOException
-
flush
- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException
-
onWritePossible
- Specified by:
onWritePossiblein interfacejakarta.servlet.WriteListener- Throws:
IOException
-
onError
- Specified by:
onErrorin interfacejakarta.servlet.WriteListener
-