sending commands in body of HTTP with urllib2

A

Astan Chee

Hi,
Im trying to implement the logic from
http://www.hypothetic.org/docs/msn/general/http_connections.php to a
simple python code using urllib2 and some parts of urllib. Im behind a
http proxy that requires authentication that is why Im using urllib2. Im
asking for help on how to send commands in a body of a HTTP before
requesting for response. What am I doing wrong? I only get the response
from the server but my commands never seem to be acknowledged or
properly handled. Below is my code:

import urllib2
import base64
import urllib

USER='user'
PASS='pass'

proxy_info = {'host' : "proxy.com.au",'port' : 8080}

# build a new opener that uses a proxy requiring authorization
proxy_support = urllib2.ProxyHandler({"http" : \
"http://%(host)s:%(port)d" % proxy_info})
opener = urllib2.build_opener(proxy_support, urllib2.HTTPHandler)

user_pass = base64.encodestring('%s:%s' %
(urllib.unquote(USER),urllib.unquote(PASS)))
authheader = "Basic %s" % user_pass

opener.addheaders = [('Accept-Language','en-us'),
('Accept-Encoding','gzip, deflate'),
('Host','gateway.messenger.hotmail.com'),
('Proxy-Connection','Keep-Alive'),
('Connection','Keep-Alive'),
('Pragma','no-cache'),
('Content-Type','application/x-msn-messenger'),
('User-agent','MSMSGS'),
('Accept','*/*'),
('Proxy-authorization',authheader)]

# install it
urllib2.install_opener(opener)

# use it
url =
'http://gateway.messenger.hotmail.co...ction=open&Server=NS&IP=messenger.hotmail.com'
values = 'VER 5 MSNP8 CVR0'

f = urllib2.urlopen(url,values)
print f.headers
print f.read()

Thanks for any help!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top