3

I receive this error Unhandled Exception: FormatException: Invalid HTTP header field when my header value contain accent: village_name=moapé.

How to encode header to avoid this. This my code:

Map<String, String> headers = {"Content-type": "application/json", "cookie": cookies};

http.Response response = await http.get(url, headers: headers);

1 Answer 1

4

I create a function use uri.encodecomponent to solve my problem this my code:

convert(value){
    /*
      Convertir les valeurs pour eviter que les accents créent des problémes
      dans la partie header
    */

    return Uri.encodeComponent(value.toString());
  }```
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.