Package io.grpc.stub

Class MetadataUtils

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

      • newAttachHeadersInterceptor

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

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