Strange behavior of requests, adding newlines and commas

When making a request using `requests` library and passing params as an argument, it URL encodes the parameters leaving the query part of the URL like so:  
`https://rest.uniprot.org/uniprotkb/search?query=%28ec%3A%2A%29&size=500&format=json&cursor=i6v0ks5l9w7z9bvjh2h9riak0edmthh17oyjd2k0`  
This shouldn't be a problem and if you query using `curl`, `wget` or even the web browser, you get the json file as normal. Even with different **cursor** parameter with `requests` is not a problem either. But with this specific cursor the content is splitted in 500 lines (due to the size parameter I guess) with a newline plus a comma, making json parse impossible.

## Expected Result

I expect the contents in a single line without adding newlines or commas

## Actual Result

The content is splitted in 500 lines (due to the size parameter I guess) with a newline plus a comma, making json parse impossible.

## Reproduction Steps

I don't know for how long these cursors are going to work. I have only found this cursor to not work properly.

With this code can be seen:
```python
import requests
params = {
    'query': '(ec:*)',
    'size': 500,
    'format': 'json',
    'cursor': 'i6v0ks5l9w7z9bvjh2h9riak0edmthh17oyjd2k0'
}
response = requests.get('https://rest.uniprot.org/uniprotkb/search', params)
response.text[12865:12885]
# >>> 'UPI0000099733"}},\n,{'
response.text.count(',\n,')
# >>> 499
```
This cursor doesn't present the same problem: _i6v1q9nglzhbl5g7sq9l9fvt8n5crpjx8gxbio1d_
```python
import requests
params = {
    'query': '(ec:*)',
    'size': 500,
    'format': 'json',
    'cursor': 'i6v1q9nglzhbl5g7sq9l9fvt8n5crpjx8gxbio1d'
}
response = requests.get('https://rest.uniprot.org/uniprotkb/search', params)
response.text.count(',\n,')
# >>> 0
```

`urllib.request` doesn't have this problem either: 
```python
import urllib.request
url = 'https://rest.uniprot.org/uniprotkb/search?query=%28ec%3A%2A%29&size=500&format=json&cursor=i6v0ks5l9w7z9bvjh2h9riak0edmthh17oyjd2k0'
r = urllib.request.urlopen(url)
content = r.read()
text = content.decode('utf-8')
text[12865:12885]
# >>> 'UPI0000099733"}},{"e'
r.close()
```

And if you pass the query directly in the url, requests will not http encode it, and the problem is not present:
```python
import requests
params = {
    'size': 500,
    'format': 'json',
    'cursor': 'i6v0ks5l9w7z9bvjh2h9riak0edmthh17oyjd2k0'
}
response = requests.get('https://rest.uniprot.org/uniprotkb/search?query=(ec:*)', params)
response.text[12865:12885]
# >>> 'UPI0000099733"}},\n,{'
response.text.count(',\n,')
# >>> 499
```

## System Information

    $ python -m requests.help

```json
{
  "chardet": {
    "version": "4.0.0"
  },
  "charset_normalizer": {
    "version": "3.0.1"
  },
  "cryptography": {
    "version": ""
  },
  "idna": {
    "version": "3.4"
  },
  "implementation": {
    "name": "CPython",
    "version": "3.10.6"
  },
  "platform": {
    "release": "5.19.0-35-generic",
    "system": "Linux"
  },
  "pyOpenSSL": {
    "openssl_version": "",
    "version": null
  },
  "requests": {
    "version": "2.28.2"
  },
  "system_ssl": {
    "version": "30000020"
  },
  "urllib3": {
    "version": "1.26.14"
  },
  "using_charset_normalizer": false,
  "using_pyopenssl": false
}
```


Requests doesn't alter response bodies at all. The behaviour you're observing is happening on the server side. If you check other metadata like the content-length header you'll be able to confirm the for yourself

Maybe, but there is no Content-Length on the headers, probably because Content-Encoding is gzip. But I can test the following:

```python
# test.py
import gzip
import urllib.request
import requests

url = 'https://rest.uniprot.org/uniprotkb/search?query=%28ec%3A%2A%29&size=500&format=json&cursor=i6v0ks5l9w7z9bvjh2h9riak0edmthh17oyjd2k0'
response = requests.get(url)
with open('requests.json', 'w') as f:
    f.write(response.text)

with urllib.request.urlopen(url) as r:
    with open('urllib.json', 'wb') as f:
        f.write(r.read())

with requests.get(url, stream=True) as r:
    with open('requests_gzip.json', 'wb') as f:
        with gzip.open(r.raw) as g:
            f.write(g.read())
```

And on the terminal:
```bash
python test.py
wget 'https://rest.uniprot.org/uniprotkb/search?query=%28ec%3A%2A%29&size=500&format=json&cursor=i6v0ks5l9w7z9bvjh2h9riak0edmthh17oyjd2k0' -O wget.json
curl 'https://rest.uniprot.org/uniprotkb/search?query=%28ec%3A%2A%29&size=500&format=json&cursor=i6v0ks5l9w7z9bvjh2h9riak0edmthh17oyjd2k0' > curl.json
sha256sum wget.json 
> e2afb55fcc54de947fe655dc9a246e46d64bad6bfaf55f19b99f30413d23f07b  wget.json
sha256sum curl.json 
> e2afb55fcc54de947fe655dc9a246e46d64bad6bfaf55f19b99f30413d23f07b  curl.json
sha256sum urllib.json 
> e2afb55fcc54de947fe655dc9a246e46d64bad6bfaf55f19b99f30413d23f07b  urllib.json
sha256sum requests.json 
> 886d788b3d219ad9fa23fa43787277511aa5e8e888bbca0d07dbb6eee5ca2f49  requests.json
sha256sum requests_gzip.json 
> 886d788b3d219ad9fa23fa43787277511aa5e8e888bbca0d07dbb6eee5ca2f49  requests_gzip.json
```

Edit: I added the `gzip` version and it seems strange that gives the unexpected result with the newlines. I don't know what `wget`, `curl`, and `urllib` are doing in order to get the expected result.

```py
#!/usr/bin/env python3
import requests

params = {
    'query': '(ec:*)',
    'size': 500,
    'format': 'json',
    'cursor': 'i6v0ks5l9w7z9bvjh2h9riak0edmthh17oyjd2k0'
}

a = requests.get('https://rest.uniprot.org/uniprotkb/search', params)
a.text[12865:12885]

a.text.count(',\n')
with open('requests.json', 'w') as f:
  f.write(a.text)
print(a.text)
```



```bash
pc@gpuslave:~/Documents/rq$ sha3sum curl.json 
597e92de5bc3631af24039ad74d64db09a1927e88a240e2359bea8d3  curl.json
pc@gpuslave:~/Documents/rq$ sha3sum requests.json 
597e92de5bc3631af24039ad74d64db09a1927e88a240e2359bea8d3  requests.json
```
I don't know what I changed but it produces the same sha3sum for me.

> Maybe, but there is no Content-Length on the headers, probably because Content-Encoding is gzip. But I can test the following:
> 
> ```python
> # test.py
> import gzip
> import urllib.request
> import requests
> 
> url = 'https://rest.uniprot.org/uniprotkb/search?query=%28ec%3A%2A%29&size=500&format=json&cursor=i6v0ks5l9w7z9bvjh2h9riak0edmthh17oyjd2k0'
> response = requests.get(url)
> with open('requests.json', 'w') as f:
>     f.write(response.text)
> 
> with urllib.request.urlopen(url) as r:
>     with open('urllib.json', 'wb') as f:
>         f.write(r.read())
> 
> with requests.get(url, stream=True) as r:
>     with open('requests_gzip.json', 'wb') as f:
>         with gzip.open(r.raw) as g:
>             f.write(g.read())
> ```
> 
> And on the terminal:
> ```bash
> python test.py
> wget 'https://rest.uniprot.org/uniprotkb/search?query=%28ec%3A%2A%29&size=500&format=json&cursor=i6v0ks5l9w7z9bvjh2h9riak0edmthh17oyjd2k0' -O wget.json
> curl 'https://rest.uniprot.org/uniprotkb/search?query=%28ec%3A%2A%29&size=500&format=json&cursor=i6v0ks5l9w7z9bvjh2h9riak0edmthh17oyjd2k0' > curl.json
> sha256sum wget.json 
> > e2afb55fcc54de947fe655dc9a246e46d64bad6bfaf55f19b99f30413d23f07b  wget.json
> sha256sum curl.json 
> > e2afb55fcc54de947fe655dc9a246e46d64bad6bfaf55f19b99f30413d23f07b  curl.json
> sha256sum urllib.json 
> > e2afb55fcc54de947fe655dc9a246e46d64bad6bfaf55f19b99f30413d23f07b  urllib.json
> sha256sum requests.json 
> > 886d788b3d219ad9fa23fa43787277511aa5e8e888bbca0d07dbb6eee5ca2f49  requests.json
> sha256sum requests_gzip.json 
> > 886d788b3d219ad9fa23fa43787277511aa5e8e888bbca0d07dbb6eee5ca2f49  requests_gzip.json
> ```
> 
> Edit: I added the `gzip` version and it seems strange that gives the unexpected result with the newlines. I don't know what `wget`, `curl`, and `urllib` are doing in order to get the expected result.

The gzip version shows that this is happening on the server side. The server is responding in a way that creates this behavior. This isn't a bug in requests. You can have requests only accept non-gzip compression encoding by specifying the Accept-Encoding header yourself if you feel that's the issue, but requests isn't generating the response body and you got the raw data directly with the same problem. 

@sigmavirus24 Indeed, I agree. Thanks for the idea to specify json in the Accept-Encoding. I think it could have worked and I didn't think of it myself. Now it's too late though, the response is returning non-gzip already by default, maybe they realized of the problem and it looks it was related to the compression mechanism, because the problem vanished. Or not because I specified gzip as Accept-Encoding, forcing the server to return the content gzipped, and to my surprise the problem is not present either.

So @PwnedDev, now I'm not able to reproduce the error anymore either.