Question about httplib and HTTP response 100 Continue

Marco V. Caamaño Castro mvcc_cr at yahoo.com
Sun Apr 14 22:40:24 EDT 2002


I've been trying to figure out why this code[1] does not work[2] on
connecting with a IIS server, but it works with Apache on Linux. I found
that using curl to post the request works. Digging into the response I
got using curl I found that the server is first sending a HTTP 100
Continue response and then the result of the post:

-----------------------
HTTP/1.1 100 Continue
Server: Microsoft-IIS/4.0
Date: Mon, 15 Apr 2002 00:49:27 GMT

HTTP/1.1 200 OK
Server: Microsoft-IIS/4.0
Date: Mon, 15 Apr 2002 00:49:27 GMT
Connection: close
Content-Type: x-data/xact-error
-----------------------

but apache just outputs the results right away:

-----------------------
HTTP/1.1 200 OK
Date: Mon, 15 Apr 2002 00:38:17 GMT
Server: Apache/1.3.22 (Unix) Debian/GNU mod_ssl/2.8.5 OpenSSL/0.9.6a PHP/4.1.0RC2
X-Powered-By: PHP/4.1.0RC2
Transfer-Encoding: chunked
Content-Type: text/html; charset=iso-8859-1
-----------------------

So, does the httplib work when it encounters a 100-Continue response?

I would really apreciate a little help here as I am stuck, I can't
figure out why using the httplib library doesn't work with this server.


Marco C


[1]:
def testurl():
	print '\n\nUsing HTTPS request'
	body=fmsg('\x82test')
	host=("ssl.pgs.wcom.net:443")
	hs=httplib.HTTPS()
	hs.set_debuglevel(4)
	hs.connect(host)
	hs.putrequest('POST','/scripts/gateway.dll?Transact')
	hs.putheader('Content-Type','x-Visa-II/x-auth')
	hs.putheader('Content-Length', str(len(body)))
	hs.endheaders()
	hs.send(body)
	status, reason, header= hs.getreply()
	data=hs.getfile().read()
	print data
	print status
	return

[2]:
Using HTTPS request
send: 'POST /scripts/gateway.dll?Transact HTTP/1.0\r\n'
send: 'Content-Type: x-Visa-II/x-auth\r\n'
send: 'Content-Length: 5\r\n'
send: '\r\n'
send: '\x82test'
Traceback (most recent call last):
  File "test.py", line 4, in ?
    misc_func.testurl2()
  File "misc_func.py", line 180, in testurl2
    status, reason, header= hs.getreply()
  File "/usr/lib/python2.2/httplib.py", line 728, in getreply
    response = self._conn.getresponse()
  File "/usr/lib/python2.2/httplib.py", line 570, in getresponse
    response = self.response_class(self.sock, self.debuglevel)
  File "/usr/lib/python2.2/httplib.py", line 98, in __init__
    self.fp = sock.makefile('rb', 0)
  File "/usr/lib/python2.2/httplib.py", line 607, in makefile
    buf = self.__ssl.read()
socket.sslerror: (5, 'EOF occurred in violation of protocol')


-- 

Marco V. Caamaño Castro


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com






More information about the Python-list mailing list