python - Post sentence - Info not reaching to web server -


the thing info i'm sending (alexis ahumada 1990) never stays on server log (www.inf.utfsm.cl/~mvaras/tarea1.log) i'd want know i'm doing wrong.

#!/usr/bin/env python   import socket import sys  host = 'www.inf.utfsm.cl' = '/~mvaras/tarea1.php' ua = 'tarea1' port = 80  try:   sock = socket.socket(socket.af_inet, socket.sock_stream) except socket.error, msg:   sys.stderr.write("[error] %s\n" % msg[1])   sys.exit(1)  try:   sock.connect((host, port)) except socket.error, msg:   sys.stderr.write("[error] %s\n" % msg[1])   sys.exit(2)  sock.send("get %s http/1.0\r\nhost: %s\r\n\r\nuser-agent: %s\r\n\r\n" % (get, host, ua)) sock.send("post /~mvaras/tarea1.php http/1.0 user-agent:tarea1 nombre=alexis+ahumada&rut=1990")   data = sock.recv(1024) string = "" while len(data):   string = string + data   data = sock.recv(1024)      print string      sys.exit(0) 

you cannot post server, have post url. in request specified /~mvaras/tarea1.php url didn't post.

besides, not using http 1.1 because did not include host header specified on the section 14 of rfc

a client must include host header field in http/1.1 request messages . if requested uri not include internet host name service being requested, host header field must given empty value.

on side note please keep in mind using http on sockets if need. if want http data, use implementations of higher level.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -