Skip to content

Fix issue with twisted getClient()

Mattias Ellert requested to merge ellert/arc:twisted-get-client-fix into master

MR !236 (merged) attempted to fix BUGZ-3733, but it did not work as expected. The code now fails with the error:

 File "/builddir/build/BUILD/nordugrid-arc-trunk/src/services/acix/cacheserver/cacheresource.py", line 24, in render_GET
    client = clienthost + "/" + request.getClientIP()
builtins.TypeError: unsupported operand type(s) for +: 'IPv4Address' and 'str'

The new getClientAddress() function returns an IAddress object and not a string, which causes the error.

The getClientAddress() function is a replacement for the deprecated (but not yet removed) getClientIP() function, not for getClient() as was assumed when the original fix was written.

The getClient() function has been deprecated for many twisted releases, and was removed without a replacement. It has also for many twisted releases before it was removed been redefined from its original implementation and simply been an alias for getClientIP().

This MR copies the original definition of getClient() from an ancient twisted release to restore the intended behavior of the code.

Merge request reports