[Updated] D12047: test-http-bad-server: refactor the writing logic to avoid early return
marmoute (Pierre-Yves David)
phabricator at mercurial-scm.org
Tue Jan 25 09:19:02 UTC 2022
Closed by commit rHG98c502a2c462: test-http-bad-server: refactor the writing logic to avoid early return (authored by marmoute).
This revision was automatically updated to reflect the committed changes.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D12047?vs=31871&id=31923
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D12047/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D12047
AFFECTED FILES
tests/testlib/badserverext.py
CHANGE DETAILS
diff --git a/tests/testlib/badserverext.py b/tests/testlib/badserverext.py
--- a/tests/testlib/badserverext.py
+++ b/tests/testlib/badserverext.py
@@ -108,22 +108,25 @@
orig = object.__getattribute__(obj, '_orig')
bmethod = method.encode('ascii')
func = getattr(orig, method)
- # No byte limit on this operation. Call original function.
+
+ if remaining:
+ remaining = max(0, remaining)
+
if not remaining:
- result = func(data, *args, **kwargs)
- obj._writelog(b'%s(%d) -> %s' % (bmethod, len(data), data))
- return result
-
- remaining = max(0, remaining)
-
- if remaining > 0:
+ newdata = data
+ else:
if remaining < len(data):
newdata = data[0:remaining]
else:
newdata = data
+ remaining -= len(newdata)
+ self.remaining_send_bytes = remaining
- remaining -= len(newdata)
+ result = func(newdata, *args, **kwargs)
+ if remaining is None:
+ obj._writelog(b'%s(%d) -> %s' % (bmethod, len(data), data))
+ else:
obj._writelog(
b'%s(%d from %d) -> (%d) %s'
% (
@@ -135,11 +138,7 @@
)
)
- result = func(newdata, *args, **kwargs)
-
- self.remaining_send_bytes = remaining
-
- if remaining <= 0:
+ if remaining is not None and remaining <= 0:
obj._writelog(b'write limit reached; closing socket')
object.__getattribute__(obj, '_cond_close')()
raise Exception('connection closed after sending N bytes')
To: marmoute, #hg-reviewers, Alphare
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20220125/b155102b/attachment-0002.html>
More information about the Mercurial-patches
mailing list