Repository: astropy/astroquery

Issue:
Deprecate commons.send_request
Once the last usage of ``commons.send_request`` is removed, see #824, it should be deprecated in favour of ``BaseQuery._request``.

Discussion:
codecov[bot]: # [Codecov](https://codecov.io/gh/astropy/astroquery/pull/2160?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=astropy) Report
> Merging [#2160](https://codecov.io/gh/astropy/astroquery/pull/2160?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=astropy) (03f7693) into [main](https://codecov.io/gh/astropy/astroquery/commit/1aba55ed17a0b6c5ff7414f8104af82b567f16d3?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=astropy) (1aba55e) will **increase** coverage by `0.00%`.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/astropy/astroquery/pull/2160/graphs/tree.svg?width=650&height=150&src=pr&token=LtKgPxSMMc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=astropy)](https://codecov.io/gh/astropy/astroquery/pull/2160?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=astropy)

```diff
@@           Coverage Diff           @@
##             main    #2160   +/-   ##
=======================================
  Coverage   66.24%   66.24%           
=======================================
  Files         419      419           
  Lines       28118    28124    +6     
=======================================
+ Hits        18626    18632    +6     
  Misses       9492     9492           
```


| [Impacted Files](https://codecov.io/gh/astropy/astroquery/pull/2160?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=astropy) | Coverage Δ | |
|---|---|---|
| [astroquery/utils/commons.py](https://codecov.io/gh/astropy/astroquery/pull/2160/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=astropy#diff-YXN0cm9xdWVyeS91dGlscy9jb21tb25zLnB5) | `77.72% <100.00%> (+0.11%)` | :arrow_up: |
| [astroquery/utils/tests/test\_utils.py](https://codecov.io/gh/astropy/astroquery/pull/2160/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=astropy#diff-YXN0cm9xdWVyeS91dGlscy90ZXN0cy90ZXN0X3V0aWxzLnB5) | `93.13% <100.00%> (+0.15%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/astropy/astroquery/pull/2160?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=astropy).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=astropy)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/astropy/astroquery/pull/2160?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=astropy). Last update [1aba55e...03f7693](https://codecov.io/gh/astropy/astroquery/pull/2160?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=astropy). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=astropy).


Patch:
diff --git a/astroquery/utils/commons.py b/astroquery/utils/commons.py
index cba49f2a..de1e3a02 100644
--- a/astroquery/utils/commons.py
+++ b/astroquery/utils/commons.py
@@ -16,7 +16,7 @@ import six
 import astropy.units as u
 from astropy import coordinates as coord
 from collections import OrderedDict
-from astropy.utils import minversion
+from astropy.utils import deprecated, minversion
 import astropy.utils.data as aud
 from astropy.io import fits, votable
 
@@ -60,6 +60,7 @@ ASTROPY_LT_4_1 = not minversion('astropy', '4.1')
 ASTROPY_LT_4_3 = not minversion('astropy', '4.3')
 
 
+@deprecated('0.4.4', alternative='astroquery.query.BaseQuery._request')
 def send_request(url, data, timeout, request_type='POST', headers={},
                  **kwargs):
     """


Test patch:
diff --git a/astroquery/utils/tests/test_utils.py b/astroquery/utils/tests/test_utils.py
index 5ac3ea41..3e4d78c8 100644
--- a/astroquery/utils/tests/test_utils.py
+++ b/astroquery/utils/tests/test_utils.py
@@ -15,6 +15,7 @@ import astropy.io.votable as votable
 import astropy.units as u
 from astropy.table import Table
 import astropy.utils.data as aud
+from astropy.utils.exceptions import AstropyDeprecationWarning
 
 from ...utils import chunk_read, chunk_report, class_or_instance, commons
 from ...utils.process_asyncs import async_to_sync_docstr, async_to_sync
@@ -96,8 +97,9 @@ def test_send_request_post(monkeypatch):
                                    status_code=status_code)
     monkeypatch.setattr(requests, 'post', mock_post)
 
-    response = commons.send_request('https://github.com/astropy/astroquery',
-                                    data=dict(msg='ok'), timeout=30)
+    with pytest.warns(AstropyDeprecationWarning):
+        response = commons.send_request('https://github.com/astropy/astroquery',
+                                            data=dict(msg='ok'), timeout=30)
     assert response.url == 'https://github.com/astropy/astroquery'
     assert response.data == dict(msg='ok')
     assert 'astroquery' in response.headers['User-Agent']
@@ -112,8 +114,9 @@ def test_send_request_get(monkeypatch):
         req.raise_for_status = lambda: None
         return req
     monkeypatch.setattr(requests, 'get', mock_get)
-    response = commons.send_request('https://github.com/astropy/astroquery',
-                                    dict(a='b'), 60, request_type='GET')
+    with pytest.warns(AstropyDeprecationWarning):
+        response = commons.send_request('https://github.com/astropy/astroquery',
+                                        dict(a='b'), 60, request_type='GET')
     assert response.url == 'https://github.com/astropy/astroquery?a=b'
 
 
@@ -125,15 +128,18 @@ def test_quantity_timeout(monkeypatch):
         req.raise_for_status = lambda: None
         return req
     monkeypatch.setattr(requests, 'get', mock_get)
-    response = commons.send_request('https://github.com/astropy/astroquery',
-                                    dict(a='b'), 1 * u.min, request_type='GET')
+    with pytest.warns(AstropyDeprecationWarning):
+        response = commons.send_request('https://github.com/astropy/astroquery',
+                                        dict(a='b'), 1 * u.min,
+                                        request_type='GET')
     assert response.url == 'https://github.com/astropy/astroquery?a=b'
 
 
 def test_send_request_err():
     with pytest.raises(ValueError):
-        commons.send_request('https://github.com/astropy/astroquery',
-                             dict(a='b'), 60, request_type='PUT')
+        with pytest.warns(AstropyDeprecationWarning):
+            commons.send_request('https://github.com/astropy/astroquery',
+                                 dict(a='b'), 60, request_type='PUT')
 
 
 col_1 = [1, 2, 3]