http to https forwarding

Gerhard Häring gerhard.haering at gmx.de
Wed Jul 24 17:54:46 EDT 2002


* David Iungerich <david.iungerich at kwe.com> [2002-07-24 16:44 -0500]:
> Has anyone setup anything to implement the following scenario.

I recently did a proof-of-concept:

from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
import BaseHTTPServer
import urllib2

FORWARD_URL_START = "https://sourceforge.net"

class ProxyRequestHandler(BaseHTTPRequestHandler):
    def do_GET(self):
        f = urllib2.urlopen(FORWARD_URL_START + self.path)
        data = f.read()
        content_type = f.info()["Content-Type"]
        self.send_response(200)
        self.send_header("Content-Type", content_type)
        self.end_headers()
        self.wfile.write(data)

def main():
    BaseHTTPServer.test(ProxyRequestHandler)

if __name__ == "__main__":
    main()

> I need to do it, and fast.

Was that fast enough? ;-)

> I need to an http to https forwarder.   My scenario is as follows:
> 
> I have an appserver that needs to POST http requests to another
> company's appserver. Unfortunately, the particular product we are
> using has issues being able to send https, and the other company
> requires it. They have issued us certificates to talk to them.

For certificate handling you need something better than the standard
Python SSL. Both PyOpenSSL or m2crypto can do certificates.

Oh well, I promised to look into this and write a PEP, but was occopied
with other stuff lately :-/

Gerhard
-- 
mail:   gerhard <at> bigfoot <dot> de       registered Linux user #64239
web:    http://www.cs.fhm.edu/~ifw00065/    OpenPGP public key id AD24C930
public key fingerprint: 3FCC 8700 3012 0A9E B0C9  3667 814B 9CAA AD24 C930
reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b')))




More information about the Python-list mailing list