Changeset 205
- Timestamp:
- 05/19/06 23:29:43 (3 years ago)
- Files:
-
- trunk/openlayers/examples/proxy.cgi (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openlayers/examples/proxy.cgi
r195 r205 19 19 url = fs.getvalue('url', "http://openlayers.org") 20 20 21 if url.startswith("http://") or url.startswith("https://"): 21 allowedHosts = ['www.openlayers.org', 'openlayers.org', 'octo.metacarta.com'] 22 allowedHosts = object() 23 host = url.split("/")[2] 22 24 23 y = urllib.urlopen(url) 25 try: 26 if allowedHosts and not host in allowedHosts: 27 print "Status: 502 Bad Gateway" 28 print "Content-Type: text/plain" 29 print 30 print "This proxy does not allow you to access that location." 24 31 25 headers = str(y.info()).split('\n') 26 for h in headers: 27 if h.startswith("Content-Type:"): 28 print h 29 print 32 elif url.startswith("http://") or url.startswith("https://"): 30 33 31 print y.read() 32 33 y.close() 34 else: 35 print """Content-Type: text/plain 36 34 y = urllib.urlopen(url) 35 36 headers = str(y.info()).split('\n') 37 for h in headers: 38 if h.startswith("Content-Type:"): 39 print h 40 print 41 42 print y.read() 43 44 y.close() 45 else: 46 print """Content-Type: text/plain 47 37 48 Illegal request.""" 49 except Exception, E: 50 print "Status: 500 Unexpected Error" 51 print "Content-Type: text/plain" 52 print 53 print "Some unexpected error occurred. Error text was:", E
