Interface GrpcServerTransport
public interface GrpcServerTransport
The HTTP side of one gRPC call on the server, implemented by the HTTP
server for an HTTP/2 stream and by GrpcServer for gRPC-Web over HTTP/1.1.
Header lines are name: value strings.
-
Method Summary
Modifier and TypeMethodDescriptionvoidEnds the response with these trailers, aftersendHeaders(String, List); null ends it with no trailers.booleanbyte[]read()The next request bytes, blocking until some arrive.voidsend(byte[] data) Sends response bytes, aftersendHeaders(String, List).voidsendHeaders(String contentType, List<String> lines) Sends the response headers: status 200 and this content type.voidtrailersOnly(String contentType, List<String> lines) Answers with headers only, ending the stream: a gRPC "trailers-only" response, used when the call fails before any message was sent.
-
Method Details
-
read
The next request bytes, blocking until some arrive.- Returns:
- the bytes, or null once the client ended its side
- Throws:
IOException- when the stream was reset or the connection failed
-
sendHeaders
Sends the response headers: status 200 and this content type.- Parameters:
contentType- the response content typelines- further headers- Throws:
IOException- when the stream is gone
-
send
Sends response bytes, aftersendHeaders(String, List).- Parameters:
data- the bytes- Throws:
IOException- when the stream is gone
-
finish
Ends the response with these trailers, aftersendHeaders(String, List); null ends it with no trailers.- Parameters:
trailers- the trailer lines, or null- Throws:
IOException- when the stream is gone
-
trailersOnly
Answers with headers only, ending the stream: a gRPC "trailers-only" response, used when the call fails before any message was sent.- Parameters:
contentType- the response content typelines- the headers, the status among them- Throws:
IOException- when the stream is gone
-
isCancelled
boolean isCancelled()- Returns:
- whether the client cancelled or the stream was reset
-