bool append_header_value(JSContext *cx, HandleObject self, HandleValue name, HandleValue value,
                         const char *fun_name) {
  NORMALIZE_NAME(name, fun_name)
  NORMALIZE_VALUE(value, fun_name)

  // Ensure that any host-side values have been applied JS-side.
  RootedValue v(cx);
  if (!ensure_value_for_header(cx, self, normalized_name, &v))
    return false;

  Mode mode = detail::mode(self);
  if (mode != Mode::Standalone) {
    AppendHeaderOperation *op;
    if (mode == Mode::ProxyToRequest)
      op = (AppendHeaderOperation *)xqd_req_header_append;
    else
      op = (AppendHeaderOperation *)xqd_resp_header_append;
    if (!HANDLE_RESULT(
            cx, op(handle(self), name_chars.get(), name_len, value_chars.get(), value_len))) {
      return false;
    }
  }

  return append_header_value_to_map(cx, self, normalized_name, &normalized_value);
}
bool append_header_value(JSContext *cx, HandleObject self, HandleValue name, HandleValue value,
                         const char *fun_name) {
  NORMALIZE_NAME(name, fun_name)
  NORMALIZE_VALUE(value, fun_name)

   
  RootedValue v(cx);
  if (!ensure_value_for_header(cx, self, normalized_name, &v))
    return false;

  Mode mode = detail::mode(self);
  if (mode != Mode::Standalone) {
    AppendHeaderOperation *op;
    if (mode == Mode::ProxyToRequest)
      op = (AppendHeaderOperation *)xqd_req_header_append;
    else
      op = (AppendHeaderOperation *)xqd_resp_header_append;
    if (!HANDLE_RESULT(
            cx, op(handle(self), name_chars.get(), name_len, value_chars.get(), value_len))) {
      return false;
    }
  }

  return append_header_value_to_map(cx, self, normalized_name, &normalized_value);
}