Object - grpc : Headers

Provides the actions to read/write header values in a gRPC request/response message.

Methods

Checks whether the requested header exists.

Returns the header value with the specified header name.

Gets all the transport headers with the specified header name.

Sets the value of a transport header.

Adds the specified key/value pair as an HTTP header to the request.

Removes a transport header from the request.

Removes all the transport headers from the message.

exists

(string headerName)

returns boolean

Checks whether the requested header exists.

 boolean result = headers.exists("content-type");

Parameters

  • headerName string
  • The header name

  • Return Type

    (boolean)
  • True if header exists or else false

get

(string headerName)

returns string?

Returns the header value with the specified header name. If there are more than one header values for the specified header name, the first value is returned.

 string? result = headers.get("content-type");

Parameters

  • headerName string
  • The header name

  • Return Type

    (string?)
  • First header value if exists or else ()

getAll

(string headerName)

returns string[]

Gets all the transport headers with the specified header name.

 string[] result = headers.getAll("content-type");

Parameters

  • headerName string
  • The header name

  • Return Type

    (string[])
  • Header value array

setEntry

(string headerName, string headerValue)

Sets the value of a transport header.

 headers.setEntry("content-type", "application/grpc")

Parameters

  • headerName string
  • The header name

  • headerValue string
  • The header value

addEntry

(string headerName, string headerValue)

Adds the specified key/value pair as an HTTP header to the request.

 headers.addEntry("content-type", "application/grpc")

Parameters

  • headerName string
  • The header name

  • headerValue string
  • The header value

remove

(string headerName)

Removes a transport header from the request.

 headers.remove("content-type")

Parameters

  • headerName string
  • The header name

removeAll

()

Removes all the transport headers from the message.

 headers.removeAll()