private static HttpData toHttpData(@Nullable Object value, Charset charset) {
        if (value == null) {
            // To prevent to convert null value to 'null' string.
            return HttpData.empty();
        }

        if (value instanceof Iterable) {
            final StringBuilder sb = new StringBuilder();
            ((Iterable<?>) value).forEach(v -> {
                // TODO(trustin): Inefficient double conversion. Time to write HttpDataBuilder?
                if (v instanceof HttpData) {
                    sb.append(((HttpData) v).toString(charset));
                } else if (v instanceof byte[]) {
                    sb.append(new String((byte[]) v, charset));
                } else {
                    sb.append(v);
                }
            });
            return HttpData.of(charset, sb);
        }

        if (value instanceof HttpData) {
            return (HttpData) value;
        }

        if (value instanceof byte[]) {
            return HttpData.wrap((byte[]) value);
        }

        return HttpData.of(charset, String.valueOf(value));
    }
A {@link ResponseConverterFunction} which creates an {@link HttpResponse} when:
<ul>
  <li>the {@code result} is an instance of {@link CharSequence}</li>
  <li>the {@code "content-type"} of the {@link ResponseHeaders} is {@link MediaType#ANY_TEXT_TYPE}</li>
</ul>
Note that this {@link ResponseConverterFunction} is applied to an annotated service by default,
so you don't have to specify this converter explicitly.
core/src/main/java/com/linecorp/armeria/server/annotation/StringResponseConverterFunction.java