add check_url scripts for appcast stanzas in both sever-cgi and local-cli versions (#59688)

* add check_url scripts as used for appcast stanzas in both sever-cgi as local-cli variants

* Update check_url_filename.py
This commit is contained in:
CoreCode
2019-03-08 03:12:48 +00:00
committed by Vítor Galvão
parent 84e3a84721
commit 599b40d35e
4 changed files with 96 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
#!/usr/bin/python
import cgi
import urllib2
form = cgi.FieldStorage()
url = form.getvalue("url", "")
ua = form.getvalue("user_agent", "Mozilla")
try:
headers = { 'User-Agent' : ua }
req = urllib2.Request(url, None, headers)
response = urllib2.urlopen(req)
_, params = cgi.parse_header(response.headers.get('Content-Disposition', ''))
filename = params['filename']
except Exception:
import traceback
filename = 'generic exception: ' + traceback.format_exc()
print "Content-type: text/html"
print
print """
<html>
<head><title></title></head>
<body>
%s
</body>
</html>
""" % cgi.escape(filename)
+23
View File
@@ -0,0 +1,23 @@
#!/usr/bin/python
import sys
import cgi
import urllib2
url = sys.argv[1]
headers = {'User-Agent' : 'Mozilla'}
if len(sys.argv) > 2:
ua = sys.argv[2]
headers = { 'User-Agent' : ua }
try:
req = urllib2.Request(url, None, headers)
response = urllib2.urlopen(req)
_, params = cgi.parse_header(response.headers.get('Content-Disposition', ''))
filename = params['filename']
except Exception:
import traceback
filename = 'generic exception: ' + traceback.format_exc()
print filename
+26
View File
@@ -0,0 +1,26 @@
#!/usr/bin/python
import cgi
import urllib2
form = cgi.FieldStorage()
url = form.getvalue("url", "")
try:
response = urllib2.urlopen(url)
redir = response.geturl()
except Exception:
import traceback
redir = 'generic exception: ' + traceback.format_exc()
print "Content-type: text/html"
print
print """
<html>
<head><title></title></head>
<body>
%s
</body>
</html>
""" % cgi.escape(redir)
+16
View File
@@ -0,0 +1,16 @@
#!/usr/bin/python
import sys
import cgi
import urllib2
url = sys.argv[1]
try:
response = urllib2.urlopen(url)
redir = response.geturl()
except Exception:
import traceback
redir = 'generic exception: ' + traceback.format_exc()
print redir