26 lines
670 B
Python
26 lines
670 B
Python
import socket
|
|
HOST="sso.yunhaixingtong.com"; PORT=80
|
|
body="loginname=AAA&pwd=BBB&captcha="
|
|
req=(
|
|
"POST /api/login HTTP/1.1\r\n"
|
|
f"Host: {HOST}\r\n"
|
|
"Content-Type: application/x-www-form-urlencoded\r\n"
|
|
f"Content-Length: {len(body)}\r\n"
|
|
"Connection: close\r\n"
|
|
"\r\n"
|
|
+ body
|
|
)
|
|
s=socket.create_connection((HOST,PORT),timeout=20)
|
|
s.sendall(req.encode())
|
|
data=b""
|
|
while True:
|
|
chunk=s.recv(4096)
|
|
if not chunk: break
|
|
data+=chunk
|
|
s.close()
|
|
text=data.decode('utf-8','ignore')
|
|
# print status line + headers (up to first blank line)
|
|
head=text.split("\r\n\r\n",1)[0]
|
|
print("=== RAW RESPONSE HEAD (native form POST) ===")
|
|
print(head[:1500])
|