---
title: "U6004: A header value contains a control character"
url: https://una-lang.org/en/docs/errors/U6004/
release: v0.4.0
source: https://github.com/una-lang/una/blob/v0.4.0/crates/una-explain/explain/U6004.md
---

# U6004: A header value contains a control character

`una run` and native executables abort when an operation of `Http` is given a header whose value contains a control character other than a tab: a byte below `0x20`, or `0x7f` (`spec/24 §1`). The diagnostic points at the operation. Nothing is sent.

## Why Una rejects it

It is an abort, not an `HttpError`, because a header's value is `internal` (`spec/24 §5`). A failure the program could handle would tell it whether an `internal` value holds a control character, one bit per request. An abort ends the run, which is outside the noninterference model, as running out of depth or memory is (`spec/07 §1`).

## How to fix it

A program that builds a header value from data removes the control characters first, for example with `replace`.

## The repair at a glance

`src/demo.una`

```diff
  module demo

  pub main() -> Unit
    uses @http: Http[get]
  =
-   let token = "abc\ndef"
+   let token = "abc\ndef".replace(pattern: "\n", by: "")
    let r = attempt @http.get("http://127.0.0.1:9/", headers: [Header(name: "X-Token", value: token)], key_name: None)
    unit
```

## Failing example

`una.toml`

```toml
[package]
name = "demo"
version = "0.1.0"
edition = "0.2"

[run]
entry = "demo"
grants = ["http:http://127.0.0.1:9"]
```

`src/demo.una`

```una
module demo

pub main() -> Unit
  uses @http: Http[get]
=
  let token = "abc\ndef"
  let r = attempt @http.get("http://127.0.0.1:9/", headers: [Header(name: "X-Token", value: token)], key_name: None)
  unit
```

## Fixed example

`una.toml`

```toml
[package]
name = "demo"
version = "0.1.0"
edition = "0.2"

[run]
entry = "demo"
grants = ["http:http://127.0.0.1:9"]
```

`src/demo.una`

```una
module demo

pub main() -> Unit
  uses @http: Http[get]
=
  let token = "abc\ndef".replace(pattern: "\n", by: "")
  let r = attempt @http.get("http://127.0.0.1:9/", headers: [Header(name: "X-Token", value: token)], key_name: None)
  unit
```
