private static void encodeMetadataValueAndSetHeader(String headerName, String headerValue,
      RestResponseChannel restResponseChannel) {
    try {
      headerName =
          headerName.replaceFirst(Headers.USER_META_DATA_HEADER_PREFIX, Headers.USER_META_DATA_ENCODED_HEADER_PREFIX);
      headerValue = URLEncoder.encode(headerValue, CHARSET.name());
      restResponseChannel.setHeader(headerName, headerValue);
      logger.debug("Set encoded value in response header {}", headerName);
    } catch (Exception e) {
      logger.error("Unable to set response header {} to value {}", headerName, headerValue, e);
    }
  }
The header value may require encoding to set in response header (i.e it contains non-ascii character, newline, etc)
The encoded value will be set in special header (USER_META_DATA_ENCODED_HEADER_PREFIX). The client receiving the
response will need to check these headers and perform the decode.
@param headerName the user metadata key
@param headerValue the user metadata value
@param restResponseChannel the {@link RestResponseChannel} that is used for sending the response.
ambry-api/src/main/java/com/github/ambry/rest/RestUtils.java