本文整理汇总了Python中stream.Stream.send_http_msg方法的典型用法代码示例。如果您正苦于以下问题:Python Stream.send_http_msg方法的具体用法?Python Stream.send_http_msg怎么用?Python Stream.send_http_msg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stream.Stream
的用法示例。
在下文中一共展示了Stream.send_http_msg方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from stream import Stream [as 别名]
# 或者: from stream.Stream import send_http_msg [as 别名]
def main(): # Testing HTTP/1.1
client = socket(AF_INET, SOCK_STREAM)
client.connect(ADDR)
# client.send('GET / HTTP/1.1\r\n\r\n')
data = client.recv(BUFF_SIZE)
print(':'.join(x.encode('hex') for x in data))
# send preface
client.send('\x50\x52\x49\x20\x2a\x20\x48\x54\x54\x50\x2f\x32\x2e\x30\x0d\x0a\x0d\x0a\x53\x4d\x0d\x0a\x0d\x0a')
client.send('\x00\x00\x00\x04\x00\x00\x00\x00\x00') # Setting Frame
data = client.recv(BUFF_SIZE)
print(':'.join(x.encode('hex') for x in data))
stream = Stream()
request = Request()
request.status = Status()
request.status.path = '/'
request.status.method = 'GET'
request.headers = {}
# request.headers['date'] = Header('Date', 'Sun, 06 Nov 2015 08:49:37 GMT')
msg = stream.send_http_msg(request)
print(':'.join(hex(x) for x in msg))
client.send(msg)
data = client.recv(BUFF_SIZE)
print(':'.join(x.encode('hex') for x in data))
client.send('\x00\x00\x00\x04\x01\x00\x00\x00\x00') # Setting Frame
data = client.recv(BUFF_SIZE)
print(':'.join(x.encode('hex') for x in data))