On Mon, Aug 18, 2008 at 9:36 PM, xbmuncher <[EMAIL PROTECTED]> wrote: > I tried it just like both of you suggested and sent a req object straight to > urlopen. Here is my code: > import urllib2 > url = 'https://url.com' > headers = { > 'User-Agent' : 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)', > 'Accept' : > 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5', > 'Accept-Language' : 'fr-fr,en-us;q=0.7,en;q=0.3', > 'Accept-Charset' : 'ISO-8859-1,utf-8;q=0.7,*;q=0.7' > } > > #None = GET; set values to use POST > req = urllib2.Request(url, None, headers) > handle = urllib2.urlopen(req) > resp = handle.read() > print resp.geturl() > print resp.info() > print resp > > resp.close() > > > > Here is the error msg: > Traceback (most recent call last): > File "C:\Documents and Settings\user\Desktop\https_query.py", line 16, in > <module> > handle = urllib2.urlopen(req) > File "C:\Python25\lib\urllib2.py", line 124, in urlopen > return _opener.open(url, data) > File "C:\Python25\lib\urllib2.py", line 381, in open > response = self._open(req, data) > File "C:\Python25\lib\urllib2.py", line 399, in _open > '_open', req) > File "C:\Python25\lib\urllib2.py", line 360, in _call_chain > result = func(*args) > File "C:\Python25\lib\urllib2.py", line 1115, in https_open > return self.do_open(httplib.HTTPSConnection, req) > File "C:\Python25\lib\urllib2.py", line 1080, in do_open > r = h.getresponse() > File "C:\Python25\lib\httplib.py", line 928, in getresponse > response.begin() > File "C:\Python25\lib\httplib.py", line 385, in begin > version, status, reason = self._read_status() > File "C:\Python25\lib\httplib.py", line 349, in _read_status > raise BadStatusLine(line) > BadStatusLine
What URL are you trying this against? The URL in your code "https://url.com" doesn't seem to respond at all so I can't reproduce your error. Have you tried against a well known HTTPS endpoint like "https://mail.google.com"? What happens? I'll try to guess anyway .. the Status Line in an HTTP response is the first line that gives the response code, something like "HTTP/1.1 200 OK". Maybe your server is returning malformed headers? See below for more: http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor