summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sleekxmpp/jid.py23
-rw-r--r--sleekxmpp/plugins/xep_0332/http.py6
2 files changed, 17 insertions, 12 deletions
diff --git a/sleekxmpp/jid.py b/sleekxmpp/jid.py
index 613b272e..754a3d3a 100644
--- a/sleekxmpp/jid.py
+++ b/sleekxmpp/jid.py
@@ -72,19 +72,18 @@ JID_CACHE_LOCK = threading.Lock()
JID_CACHE_MAX_SIZE = 1024
def _cache(key, parts, locked):
- JID_CACHE[key] = (parts, locked)
- if len(JID_CACHE) > JID_CACHE_MAX_SIZE:
- with JID_CACHE_LOCK:
- while len(JID_CACHE) > JID_CACHE_MAX_SIZE:
- found = None
- for key, item in JID_CACHE.items():
- if not item[1]: # if not locked
- found = key
- break
- if not found: # more than MAX_SIZE locked
- # warn?
+ with JID_CACHE_LOCK:
+ JID_CACHE[key] = (parts, locked)
+ while len(JID_CACHE) > JID_CACHE_MAX_SIZE:
+ found = None
+ for key, item in JID_CACHE.items():
+ if not item[1]: # if not locked
+ found = key
break
- del JID_CACHE[found]
+ if not found: # more than MAX_SIZE locked
+ # warn?
+ break
+ del JID_CACHE[found]
# pylint: disable=c0103
#: The nodeprep profile of stringprep used to validate the local,
diff --git a/sleekxmpp/plugins/xep_0332/http.py b/sleekxmpp/plugins/xep_0332/http.py
index 03d88b65..70bcafa6 100644
--- a/sleekxmpp/plugins/xep_0332/http.py
+++ b/sleekxmpp/plugins/xep_0332/http.py
@@ -108,6 +108,8 @@ class XEP_0332(BasePlugin):
iq['http-req']['method'] = method
iq['http-req']['resource'] = resource
iq['http-req']['version'] = '1.1' # TODO: set this implicitly
+ if 'id' in kwargs:
+ iq['id'] = kwargs["id"]
if data is not None:
iq['http-req']['data'] = data
return iq.send(
@@ -127,6 +129,8 @@ class XEP_0332(BasePlugin):
iq['http-resp']['code'] = code
iq['http-resp']['message'] = message
iq['http-resp']['version'] = '1.1' # TODO: set this implicitly
+ if 'id' in kwargs:
+ iq['id'] = kwargs["id"]
if data is not None:
iq['http-resp']['data'] = data
return iq.send(
@@ -145,6 +149,8 @@ class XEP_0332(BasePlugin):
iq['error']['code'] = ecode
iq['error']['type'] = etype
iq['error']['condition'] = econd
+ if 'id' in kwargs:
+ iq['id'] = kwargs["id"]
return iq.send(
timeout=kwargs.get('timeout', None),
block=kwargs.get('block', True),