1 """xmlrpclib.Transport implementation
7 from typing
import TYPE_CHECKING
, Tuple
9 from pip
._internal
.exceptions
import NetworkConnectionError
10 from pip
._internal
.network
.session
import PipSession
11 from pip
._internal
.network
.utils
import raise_for_status
14 from xmlrpc
.client
import _HostType
, _Marshallable
16 logger
= logging
.getLogger(__name__
)
19 class PipXmlrpcTransport(xmlrpc
.client
.Transport
):
20 """Provide a `xmlrpclib.Transport` implementation via a `PipSession`
25 self
, index_url
: str, session
: PipSession
, use_datetime
: bool = False
27 super().__init
__(use_datetime
)
28 index_parts
= urllib
.parse
.urlparse(index_url
)
29 self
._scheme
= index_parts
.scheme
30 self
._session
= session
37 verbose
: bool = False,
38 ) -> Tuple
["_Marshallable", ...]:
39 assert isinstance(host
, str)
40 parts
= (self
._scheme
, host
, handler
, None, None, None)
41 url
= urllib
.parse
.urlunparse(parts
)
43 headers
= {"Content-Type": "text/xml"}
44 response
= self
._session
.post(
50 raise_for_status(response
)
51 self
.verbose
= verbose
52 return self
.parse_response(response
.raw
)
53 except NetworkConnectionError
as exc
:
56 "HTTP error %s while getting %s",
57 exc
.response
.status_code
,