@@ -1408,7 +1408,10 @@ def _download_file_to_stream(
14081408 try :
14091409 with get_func (url , ** kwargs ) as response :
14101410 # Auto-fix missing 'api/'
1411- if response .status_code == 405 and not api_prepended :
1411+ if (
1412+ response .status_code in (404 , 405 )
1413+ and not api_prepended
1414+ ):
14121415 api_prepended = True
14131416 if (
14141417 not endpoint .startswith (self ._base_url )
@@ -1792,7 +1795,10 @@ def _upload_file(
17921795 url = self ._endpoint_to_url (endpoint , use_rest = False )
17931796 progress .set_destination_url (url )
17941797
1795- headers = kwargs .setdefault ("headers" , {})
1798+ headers = kwargs .get ("headers" )
1799+ if headers is None :
1800+ kwargs ["headers" ] = headers = {}
1801+
17961802 headers_keys_by_low_key = {key .lower (): key for key in headers }
17971803 if self ._session is None :
17981804 for key , value in self .get_headers ().items ():
@@ -1838,7 +1844,7 @@ def _upload_file(
18381844 ** kwargs
18391845 )
18401846 # Auto-fix missing 'api/'
1841- if response .status_code == 405 and not api_prepended :
1847+ if response .status_code in ( 404 , 405 ) and not api_prepended :
18421848 api_prepended = True
18431849 if (
18441850 not endpoint .startswith (self ._base_url )
@@ -1982,7 +1988,6 @@ def upload_reviewable(
19821988 content_type : Optional [str ] = None ,
19831989 filename : Optional [str ] = None ,
19841990 progress : Optional [TransferProgress ] = None ,
1985- headers : Optional [dict [str , Any ]] = None ,
19861991 ** kwargs
19871992 ) -> requests .Response :
19881993 """Upload reviewable file to server.
@@ -1997,7 +2002,6 @@ def upload_reviewable(
19972002 filename (Optional[str]): User as original filename. Filename from
19982003 'filepath' is used when not filled.
19992004 progress (Optional[TransferProgress]): Progress.
2000- headers (Optional[dict[str, Any]]): Headers.
20012005
20022006 Returns:
20032007 requests.Response: Server response.
@@ -2026,7 +2030,6 @@ def upload_reviewable(
20262030 progress = progress ,
20272031 content_type = content_type ,
20282032 filename = filename ,
2029- headers = headers ,
20302033 request_type = RequestTypes .post ,
20312034 ** kwargs
20322035 )
0 commit comments