Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What encoding does the 'text' response type option in HttpClient use?

When making an HTTP request like this:

return HttpClient.get("url", { headers: requestHeaders, responseType: 'text'});

What encoding is used when turning the response into a string?

like image 518
TigersEye120 Avatar asked Dec 01 '25 16:12

TigersEye120


1 Answers

Checking the official Angular Repository, for the Http Client we can look under common/http:

While looking into the official repo, you can only find a mention of encodings in one particular case, as seen here:

if (this.body instanceof HttpParams) {
  return 'application/x-www-form-urlencoded;charset=UTF-8';
}

Checking in the network tab of an Angular application, you can see that it does not specify the encoding type, when sending a request, however, the response headers of the response may include it in the content-type property if the sending server specified it.

Like mentioned in the comments, default is utf-8, as mentioned by jonrsharpe.

like image 109
IDK4real Avatar answered Dec 03 '25 14:12

IDK4real



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!