mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-03 03:36:44 +00:00
Avoid using possibly-private API.
This commit is contained in:
parent
23c8bde9d5
commit
6b3722d3f6
@ -30,9 +30,9 @@ from twisted.internet.task import Clock
|
|||||||
from twisted.internet import reactor
|
from twisted.internet import reactor
|
||||||
from twisted.internet.endpoints import serverFromString
|
from twisted.internet.endpoints import serverFromString
|
||||||
from twisted.web.server import Site
|
from twisted.web.server import Site
|
||||||
from twisted.web.client import HTTPConnectionPool
|
from twisted.web.client import Agent, HTTPConnectionPool
|
||||||
from hyperlink import DecodedURL
|
from hyperlink import DecodedURL
|
||||||
from treq.api import set_global_pool as set_treq_pool
|
from treq.client import HTTPClient
|
||||||
|
|
||||||
from foolscap.api import Referenceable, RemoteException
|
from foolscap.api import Referenceable, RemoteException
|
||||||
|
|
||||||
@ -1101,24 +1101,29 @@ class _HTTPMixin(_SharedMixin):
|
|||||||
|
|
||||||
@inlineCallbacks
|
@inlineCallbacks
|
||||||
def _get_istorage_server(self):
|
def _get_istorage_server(self):
|
||||||
set_treq_pool(HTTPConnectionPool(reactor, persistent=False))
|
|
||||||
swissnum = b"1234"
|
swissnum = b"1234"
|
||||||
self._http_storage_server = HTTPServer(self.server, swissnum)
|
http_storage_server = HTTPServer(self.server, swissnum)
|
||||||
|
|
||||||
# Listen on randomly assigned port:
|
# Listen on randomly assigned port:
|
||||||
tcp_address, endpoint_string = self._port_assigner.assign(reactor)
|
tcp_address, endpoint_string = self._port_assigner.assign(reactor)
|
||||||
_, host, port = tcp_address.split(":")
|
_, host, port = tcp_address.split(":")
|
||||||
port = int(port)
|
port = int(port)
|
||||||
endpoint = serverFromString(reactor, endpoint_string)
|
endpoint = serverFromString(reactor, endpoint_string)
|
||||||
self._listening_port = yield endpoint.listen(
|
listening_port = yield endpoint.listen(Site(http_storage_server.get_resource()))
|
||||||
Site(self._http_storage_server.get_resource())
|
self.addCleanup(listening_port.stopListening)
|
||||||
|
|
||||||
|
# Create HTTP client with non-persistent connections, so we don't leak
|
||||||
|
# state across tests:
|
||||||
|
treq_client = HTTPClient(
|
||||||
|
Agent(reactor, HTTPConnectionPool(reactor, persistent=False))
|
||||||
)
|
)
|
||||||
self.addCleanup(self._listening_port.stopListening)
|
|
||||||
returnValue(
|
returnValue(
|
||||||
_HTTPStorageServer.from_http_client(
|
_HTTPStorageServer.from_http_client(
|
||||||
StorageClient(
|
StorageClient(
|
||||||
DecodedURL().replace(scheme="http", host=host, port=port),
|
DecodedURL().replace(scheme="http", host=host, port=port),
|
||||||
swissnum,
|
swissnum,
|
||||||
|
treq=treq_client,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user