Body with Special Characters Gets Cut

When sending a request with special characters using the requests module, the request gets cut and is not sent fully.

This seems to be caused by the requests module calculating the length of the original string, but once the request arrives at the urllib3 module, the urllib3 module encodes the request and calculates the content length again. Unfortunately, because the request content length was already calculated and included in the headers dictionary, it gets overwritten.

## Expected Result

The request should be sent fully, including all special characters.

## Actual Result

The request gets cut off, and not all data is sent.

## Reproduction Steps

```python
import requests

### Note that the x are special characters ###
response = requests.post(url='http://127.0.0.1', data="""{"test": "××××"}""")
print(response.text)

```

## Example of the actual request:
```
POST / HTTP/1.1
Host: 127.0.0.1
User-Agent: python-requests/2.31.0
Accept-Encoding: gzip, deflate, br
Accept: */*
Connection: keep-alive
Content-Length: 16

{"test": "×××
```

As it looks the overwrite happens here:
[urllib3 connection.py#L396](https://github.com/urllib3/urllib3/blob/0ce5a89a81943e0153d3655415192e2d82f080cf/src/urllib3/connection.py#L396)

## System Information

    $ python -m requests.help

```json
{
  "chardet": {
    "version": null
  },
  "charset_normalizer": {
    "version": "3.3.2"
  },
  "cryptography": {
    "version": ""
  },
  "idna": {
    "version": "3.7"
  },
  "implementation": {
    "name": "CPython",
    "version": "3.11.9"
  },
  "platform": {
    "release": "23.5.0",
    "system": "Darwin"
  },
  "pyOpenSSL": {
    "openssl_version": "",
    "version": null
  },
  "requests": {
    "version": "2.31.0"
  },
  "system_ssl": {
    "version": "300000d0"
  },
  "urllib3": {
    "version": "2.0.7"
  },
  "using_charset_normalizer": true,
  "using_pyopenssl": false
}
```

<!-- This command is only available on Requests v2.16.4 and greater. Otherwise,
please provide some basic information about your system (Python version,
operating system, &c). -->


I'm having this issue too

Can you please explain which specific special characters result in cut of request data?

Sure, the specific one I came across was "×" - after encoding it's ```b'\xc3\x97'``` (as shown in the  "Reproduction Steps"), I also tested other characters like ```b'\xc3\x96'``` and ```b'\xc3\x95'```, and they had the same problem.
So, I believe this isn’t limited to just one specific character, it seems to be a more widespread issue.

> Sure, the specific one I came across was "×" - after encoding it's ```b'\xc3\x97'``` (as shown in the  "Reproduction Steps"), I also tested other characters like ```b'\xc3\x96'``` and ```b'\xc3\x95'```, and they had the same problem.
> So, I believe this isn’t limited to just one specific character, it seems to be a more widespread issue.

I think this might be the issue with encoding the characters is not properly working, have you tried encoding those by yourself first then passing it to data parameter?

> Sure, the specific one I came across was "×" - after encoding it's ```b'\xc3\x97'``` (as shown in the  "Reproduction Steps"), I also tested other characters like ```b'\xc3\x96'``` and ```b'\xc3\x95'```, and they had the same problem.
> So, I believe this isn’t limited to just one specific character, it seems to be a more widespread issue.

Use UTF-16 encoding or send as binary data might resolve the issue 

Yes, encoding the data before sending the request does work as a workaround
(e.g., ```requests.post(url='http://127.0.0.1', data='{"test": "××××"}'.encode())```).

However, this doesn’t address the root cause of the problem. 

The issue lies in the requests module calculating an incorrect value for the “Content-Length” header, which then overwrites the correct value from the urllib package. As a result, the urllib package uses this incorrect value, causing the request to be sent before the full body can be transmitted.

I did found a solution for my specific case, but I believe this represents a critical and widespread issue that needs to be addressed.


I have version 2.32.3 and there seems no issue:
![IMG-20240708-WA0035.jpg](https://github.com/psf/requests/assets/129309925/2b53c967-7b9a-4067-ac8a-636b996f6884)

Try upgrading requests module, hope will resolve this bug.

This is a duplicate of #6586. Please either upgrade to Requests>=2.32.0 or downgrade to `urllib3<2`. This is a behavioral change in the major version bump of urllib3.

You are right, the new version works perfectly. Thank you very much!