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 Type
    Method
    Description
    void
    finish(List<String> trailers)
    Ends the response with these trailers, after sendHeaders(String, List); null ends it with no trailers.
    boolean
     
    byte[]
    The next request bytes, blocking until some arrive.
    void
    send(byte[] data)
    Sends response bytes, after sendHeaders(String, List).
    void
    sendHeaders(String contentType, List<String> lines)
    Sends the response headers: status 200 and this content type.
    void
    trailersOnly(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

      byte[] read() throws IOException
      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

      void sendHeaders(String contentType, List<String> lines) throws IOException
      Sends the response headers: status 200 and this content type.
      Parameters:
      contentType - the response content type
      lines - further headers
      Throws:
      IOException - when the stream is gone
    • send

      void send(byte[] data) throws IOException
      Sends response bytes, after sendHeaders(String, List).
      Parameters:
      data - the bytes
      Throws:
      IOException - when the stream is gone
    • finish

      void finish(List<String> trailers) throws IOException
      Ends the response with these trailers, after sendHeaders(String, List); null ends it with no trailers.
      Parameters:
      trailers - the trailer lines, or null
      Throws:
      IOException - when the stream is gone
    • trailersOnly

      void trailersOnly(String contentType, List<String> lines) throws IOException
      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 type
      lines - 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