Skip to content

Commit 7fa90e4

Browse files
Robert F. Dickersonefiop
Robert F. Dickerson
andauthored
Allow config option for HTTP method for uploads (Artifactory) (#4553)
* allow for a config option for http method * add tests * fix tests with method * Update dvc/tree/http.py Co-authored-by: Ruslan Kuprieiev <[email protected]>
1 parent 54a48e3 commit 7fa90e4

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

dvc/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ class RelPath(str):
119119
"password": str,
120120
"ask_password": Bool,
121121
"ssl_verify": Bool,
122+
"method": str,
122123
}
123124
WEBDAV_COMMON = {
124125
"user": str,

dvc/tree/http.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def __init__(self, repo, config):
5454
self.ask_password = config.get("ask_password", False)
5555
self.headers = {}
5656
self.ssl_verify = config.get("ssl_verify", True)
57+
self.method = config.get("method", "POST")
5758

5859
def _auth_method(self, path_info=None):
5960
from requests.auth import HTTPBasicAuth, HTTPDigestAuth
@@ -194,7 +195,7 @@ def chunks():
194195
break
195196
yield chunk
196197

197-
response = self.request("POST", to_info.url, data=chunks())
198+
response = self.request(self.method, to_info.url, data=chunks())
198199
if response.status_code not in (200, 201):
199200
raise HTTPError(response.status_code, response.reason)
200201

tests/unit/remote/test_http.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,25 @@ def test_ssl_verify_disable(dvc):
103103
tree = HTTPTree(dvc, config)
104104

105105
assert tree._session.verify is False
106+
107+
108+
def test_http_method(dvc):
109+
from requests.auth import HTTPBasicAuth
110+
111+
user = "username"
112+
password = "password"
113+
auth = HTTPBasicAuth(user, password)
114+
config = {
115+
"url": "http://example.com/",
116+
"path_info": "file.html",
117+
"auth": "basic",
118+
"user": user,
119+
"password": password,
120+
"method": "PUT",
121+
}
122+
123+
tree = HTTPTree(dvc, config)
124+
125+
assert tree._auth_method() == auth
126+
assert tree.method == "PUT"
127+
assert isinstance(tree._auth_method(), HTTPBasicAuth)

0 commit comments

Comments
 (0)