Send feedback
Class Metadata (2.48.0)
Stay organized with collections
Save and categorize content based on your preferences.
Version 2.48.0 keyboard_arrow_down
public sealed class Metadata : IList<Metadata.Entry>
A collection of metadata entries that can be exchanged during a call.
gRPC supports these types of metadata:
Request headersare sent by the client at the beginning of a remote call before any request messages are sent. Response headersare sent by the server at the beginning of a remote call handler before any response messages are sent. Response trailersare sent by the server at the end of a remote call along with resulting call status.
Namespace
Grpc.Core
Assembly
Grpc.Core.Api.dll
Constructors
Initializes a new instance of Metadata
.
Fields
public const string BinaryHeaderSuffix = null
All binary headers should have this suffix.
Field Value
Type
Description
String
public static readonly Metadata Empty
An read-only instance of metadata containing no entries.
Properties
public int Count { get; }
IList`1
Property Value
Type
Description
Int32
public bool IsReadOnly { get; }
IList`1
Property Value
Type
Description
Boolean
public Metadata . Entry this [ int index ] { get ; set ; }
IList`1
Parameter
Name
Description
index
Int32
Methods
Add(Metadata.Entry)
public void Add(Metadata.Entry item)
IList`1
public void Add(string key, byte[] valueBytes)
Adds a new binary-valued metadata entry. See Metadata.Entry
constructor for params.
Parameters
Name
Description
key
String
valueBytes
Byte []
public void Add(string key, string value)
Adds a new ASCII-valued metadata entry. See Metadata.Entry
constructor for params.
IList`1
Contains(Metadata.Entry)
public bool Contains(Metadata.Entry item)
IList`1
CopyTo(Metadata.Entry[], Int32)
public void CopyTo(Metadata.Entry[] array, int arrayIndex)
IList`1
public Metadata.Entry Get(string key)
Gets the last metadata entry with the specified key.
If there are no matching entries then null
is returned.
Parameter
Name
Description
key
String
public IEnumerable<Metadata.Entry> GetAll(string key)
Gets all metadata entries with the specified key.
Parameter
Name
Description
key
String
public IEnumerator<Metadata.Entry> GetEnumerator()
IList`1
public string? GetValue(string key)
Gets the string value of the last metadata entry with the specified key.
If the metadata entry is binary then an exception is thrown.
If there are no matching entries then null
is returned.
Parameter
Name
Description
key
String
public byte[] GetValueBytes(string key)
Gets the bytes value of the last metadata entry with the specified key.
If the metadata entry is not binary the string value will be returned as ASCII encoded bytes.
If there are no matching entries then null
is returned.
Parameter
Name
Description
key
String
Returns
Type
Description
Byte []
IndexOf(Metadata.Entry)
public int IndexOf(Metadata.Entry item)
IList`1
Returns
Type
Description
Int32
Insert(Int32, Metadata.Entry)
public void Insert(int index, Metadata.Entry item)
IList`1
Remove(Metadata.Entry)
public bool Remove(Metadata.Entry item)
IList`1
public void RemoveAt(int index)
IList`1
Parameter
Name
Description
index
Int32
Send feedback
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License , and code samples are licensed under the Apache 2.0 License . For details, see the Google Developers Site Policies . Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-12-12 UTC.
Need to tell us more?
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-12-12 UTC."],[],[]]