mirror of
https://github.com/valitydev/salt.git
synced 2024-11-09 01:36:48 +00:00
Allow passing in of header
This commit is contained in:
parent
0b035341a5
commit
2336b338c5
@ -49,9 +49,13 @@ log = logging.getLogger(__name__)
|
|||||||
import msgpack
|
import msgpack
|
||||||
|
|
||||||
# TODO: put in some lib?
|
# TODO: put in some lib?
|
||||||
def frame_msg(msg):
|
def frame_msg(msg, header=None):
|
||||||
header = msgpack.dumps({'msgLen': len(msg)})
|
if header is None:
|
||||||
return '{0} {1}{2}'.format(len(header), header, msg)
|
header = {}
|
||||||
|
|
||||||
|
header['msgLen'] = len(msg)
|
||||||
|
header_packed = msgpack.dumps(header)
|
||||||
|
return '{0} {1}{2}'.format(len(header_packed), header_packed, msg)
|
||||||
|
|
||||||
|
|
||||||
def socket_frame_recv(s, recv_size=4096):
|
def socket_frame_recv(s, recv_size=4096):
|
||||||
|
Loading…
Reference in New Issue
Block a user