Package io.grpc.stub

Class MetadataUtils


  • public final class MetadataUtils
    extends java.lang.Object
    Utility functions for binding and receiving headers.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static io.grpc.ClientInterceptor newAttachHeadersInterceptor​(io.grpc.Metadata extraHeaders)
      Returns a client interceptor that attaches a set of headers to requests.
      static io.grpc.ClientInterceptor newCaptureMetadataInterceptor​(java.util.concurrent.atomic.AtomicReference<io.grpc.Metadata> headersCapture, java.util.concurrent.atomic.AtomicReference<io.grpc.Metadata> trailersCapture)
      Captures the last received metadata on a channel.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • newAttachHeadersInterceptor

        public static io.grpc.ClientInterceptor newAttachHeadersInterceptor​(io.grpc.Metadata extraHeaders)
        Returns a client interceptor that attaches a set of headers to requests.
        Parameters:
        extraHeaders - the headers to be passed by each call that is processed by the returned interceptor
      • newCaptureMetadataInterceptor

        public static io.grpc.ClientInterceptor newCaptureMetadataInterceptor​(java.util.concurrent.atomic.AtomicReference<io.grpc.Metadata> headersCapture,
                                                                              java.util.concurrent.atomic.AtomicReference<io.grpc.Metadata> trailersCapture)
        Captures the last received metadata on a channel. Useful for testing.
        Parameters:
        headersCapture - to record the last received headers
        trailersCapture - to record the last received trailers
        Returns:
        an implementation of the channel with captures installed.