[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [tor-bugs] #8605 [Stem]: Autodetect response type in ControlMessage.from_str()
#8605: Autodetect response type in ControlMessage.from_str()
----------------------------+-----------------------------------------------
Reporter: atagar | Owner: atagar
Type: enhancement | Status: reopened
Priority: normal | Milestone:
Component: Stem | Version:
Resolution: | Keywords: controller easy
Parent: | Points:
Actualpoints: |
----------------------------+-----------------------------------------------
Comment(by atagar):
> For the "synchronous" (non-650) responses, you will have exactly one
outstanding request
Yes, which is what the Controller does. It issues a GETINFO request then
knows that the reply it gets should be parsed as such. The trouble here is
that when txtorcon calls from_str() we *only* get the reply so we're
missing that context.
If you'd like then we can combine from_str() and convert() by adding an
argument to from_str() for the type. That is to say, change from_str to...
{{{
def from_str(content, msg_type = None, **kwargs):
msg = stem.socket.recv_message(StringIO.StringIO(content))
if msg_type is not None:
convert(msg_type, msg, **kwargs)
return msg
}}}
Would this work for you? I'd rather not have stem attempt to infer the
msg_type when undefined since that would lead to pretty confusing
behaviour (for instance, why are PROTOCOLINFO responses automatically
converted but not GETINFO?).
--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/8605#comment:5>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
_______________________________________________
tor-bugs mailing list
tor-bugs@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-bugs