i've never used HTTP lib before, and i found "This module defines classes 
which implement the client side of the HTTP and HTTPS protocols. It is 
normally not used directly — the module 
urllib<http://docs.python.org/library/urllib.html#module-urllib>uses it to 
handle URLs that use HTTP and HTTPS." here 
http://docs.python.org/library/httplib.html

perhaps give urllib or urllib2 a try - i use those all the time with great 
success!

cfh

On Friday, July 6, 2012 10:30:34 AM UTC-7, Adi wrote:
>
>
> Could anyone please advise if I'm doing this correctly? I'm trying to post 
> a request to Paymentech gateway. When I try the link in a browser, it 
> responds fine (https://orbitalvar1.paymentech.net/authorize:443), but 
> using post as bellow returns an error. Most likely I'm doing something 
> wrong, but can't figure out what.
>
> Thanks,
> Adnan
>
>
> *CODE:*
> import sys, httplib
>
> request = xml_string # "proper xml request..."
>
> HOST = "https://orbitalvar1.paymentech.net/authorize:443";
> # tried without https as well: HOST = "
> orbitalvar1.paymentech.net/authorize:443"
> webservice = httplib.HTTPS(HOST)
> webservice.putrequest("POST", '')
> webservice.putheader("Host", HOST)
> webservice.putheader("User-Agent","Python post")
> webservice.putheader("Content-Type", "application/PTI46")
> webservice.putheader("Content-transfer-encoding", "text")
> webservice.putheader("Content-length", "%d" % len(request))
> webservice.endheaders()
> webservice.send(request)
> statuscode, statusmessage, header = webservice.getreply()
> print statuscode, statusmessage, header
>
> *TRACEBACK:*
> Traceback (most recent call last):
>   File "/Users/adnan/web2py-dev-branch8/gluon/restricted.py", line 205, in 
> restricted
>     exec ccode in environment
>   File 
> "/Users/adnan/web2py-dev-branch8/applications/dev_thanemobile/controllers/default.py",
>  
> line 898, in <module>
>   File "/Users/adnan/web2py-dev-branch8/gluon/globals.py", line 173, in 
> <lambda>
>     self._caller = lambda f: f()
>   File 
> "/Users/adnan/web2py-dev-branch8/applications/dev_thanemobile/controllers/default.py",
>  
> line 43, in test_pmt
>     paymentech.do_request(xml_string)
>   File "applications/dev_thanemobile/modules/paymentech.py", line 46, in 
> do_request
>     webservice.endheaders()
>   File 
> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py",
>  
> line 937, in endheaders
>   File 
> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py",
>  
> line 797, in _send_output
>   File 
> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py",
>  
> line 759, in send
>   File 
> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py",
>  
> line 1140, in connect
>   File 
> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py",
>  
> line 553, in create_connection
> *gaierror: [Errno 8] nodename nor servname provided, or not known*
>
>

Reply via email to