Add "HTTP" """support"""
This commit is contained in:
parent
c08a841fe6
commit
1140ac45fe
|
@ -54,6 +54,6 @@ If you would like to implement your own authentication, make your own module to
|
|||
Establish a TCP connection with the server, and send the payload. If the server likes your payload, it will stream data to you, or accept more of your data.
|
||||
|
||||
## The payload
|
||||
Send the length of the payload as a 4-byte (32-bit) big endian unsigned integer, a null byte (hex:`00`) and a UTF-8 encoded string identifying the client's intentions follows, for example: `watch,user=fier,channel=exampleChannel,channel-password=123` or `broadcast,user=fier,user-password=123,channel=exampleChannel,channel-password=456`. The length includes only the string message, in bytes, it does not include the length itself, nor the null byte.
|
||||
First, send two new line characters (`\n\n`). Then, send the length of the payload as a 4-byte (32-bit) big endian unsigned integer, a null byte (hex:`00`) and a UTF-8 encoded string identifying the client's intentions follows, for example: `watch,user=fier,channel=exampleChannel,channel-password=123` or `broadcast,user=fier,user-password=123,channel=exampleChannel,channel-password=456`. The length includes only the string message, in bytes, it does not include the length itself, nor the null byte.
|
||||
|
||||
If you are a watcher, you will now be blasted with data. If you are a broadcaster, you can now blast data.
|
||||
|
|
|
@ -107,6 +107,7 @@ def main():
|
|||
connection.settimeout(timeout)
|
||||
connection.connect(serverAddr)
|
||||
eprint("Sending payload...")
|
||||
connection.sendall("\n\n".encode("ascii"))
|
||||
sendResponse(connection,sys.argv[2].encode("utf-8"))
|
||||
|
||||
cmd = commandToList(sys.argv[2])
|
||||
|
|
|
@ -3,6 +3,22 @@ import select
|
|||
|
||||
global clientLoopIn
|
||||
def clientLoopIn(self):
|
||||
chars = 0
|
||||
nl = False
|
||||
while chars < httpHeaderMaxSize:
|
||||
chars += 1
|
||||
char = recv(self.connection,1).decode(errors="replace")
|
||||
if char == "\n":
|
||||
if nl == True:
|
||||
chars = 0
|
||||
break
|
||||
|
||||
if nl == False:
|
||||
nl = True
|
||||
else:
|
||||
nl = False
|
||||
if chars >= httpHeaderMaxSize: return
|
||||
|
||||
cmd = getResponse(self.connection,1024).decode("utf-8")
|
||||
if cmd == False: return
|
||||
cmd = commandToList(cmd)
|
||||
|
|
Loading…
Reference in New Issue