Skip to content

Loading…

Send the most minimal body for connecting in produce.py #21

Merged
merged 1 commit into from

1 participant

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 30, 2011
  1. @jedahan
Showing with 3 additions and 6 deletions.
  1. +3 −6 produce.py
View
9 produce.py
@@ -32,11 +32,8 @@ def produce(hostname, api_key, swarm_id, resource_id, wrap):
#Sleep required to allow the swarm server time to respond with header
time.sleep(1)
- #Send a blank message to open the connection
- stripped_msg = '{"message": {"to": ["' + swarm_id + '"], "payload":}}'
- size = hex(len(stripped_msg))[2:] + "\r\n"
- chunk = stripped_msg + "\r\n"
- conn.send(size+chunk)
+ #Send a blank http body to open the connection
+ conn.send('2\r\n\n\n\r\n')
#Execute further messages
if wrap == False:
@@ -44,7 +41,7 @@ def produce(hostname, api_key, swarm_id, resource_id, wrap):
try:
msg = sys.stdin.readline()
if msg == "\n":
- stripped_msg = '{"message": {"to": ["' + swarm_id + '"], "payload":}}'
+ stripped_msg = '\n\n'
elif (len(msg) < 1):
break
else:
Something went wrong with that request. Please try again.