diff --git a/dvc/config.py b/dvc/config.py index 3fac93959..50bcfddc8 100644 --- a/dvc/config.py +++ b/dvc/config.py @@ -119,6 +119,7 @@ HTTP_COMMON = { "password": str, "ask_password": Bool, "ssl_verify": Bool, + "method": str, } WEBDAV_COMMON = { "user": str, diff --git a/dvc/tree/http.py b/dvc/tree/http.py index 39fa85deb..d084f66ee 100644 --- a/dvc/tree/http.py +++ b/dvc/tree/http.py @@ -54,6 +54,7 @@ class HTTPTree(BaseTree): # pylint:disable=abstract-method self.ask_password = config.get("ask_password", False) self.headers = {} self.ssl_verify = config.get("ssl_verify", True) + self.method = config.get("method", "POST") def _auth_method(self, path_info=None): from requests.auth import HTTPBasicAuth, HTTPDigestAuth @@ -194,7 +195,7 @@ class HTTPTree(BaseTree): # pylint:disable=abstract-method break yield chunk - response = self.request("POST", to_info.url, data=chunks()) + response = self.request(self.method, to_info.url, data=chunks()) if response.status_code not in (200, 201): raise HTTPError(response.status_code, response.reason) diff --git a/tests/unit/remote/test_http.py b/tests/unit/remote/test_http.py index a82d23642..efb8716ba 100644 --- a/tests/unit/remote/test_http.py +++ b/tests/unit/remote/test_http.py @@ -103,3 +103,25 @@ def test_ssl_verify_disable(dvc): tree = HTTPTree(dvc, config) assert tree._session.verify is False + + +def test_http_method(dvc): + from requests.auth import HTTPBasicAuth + + user = "username" + password = "password" + auth = HTTPBasicAuth(user, password) + config = { + "url": "http://example.com/", + "path_info": "file.html", + "auth": "basic", + "user": user, + "password": password, + "method": "PUT", + } + + tree = HTTPTree(dvc, config) + + assert tree._auth_method() == auth + assert tree.method == "PUT" + assert isinstance(tree._auth_method(), HTTPBasicAuth)