Skip to content
Permalink
Browse files

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
  • Loading branch information...
core-code authored and vitorgalvao committed Mar 8, 2019
1 parent 84e3a84 commit 599b40d35e9552dff3a2b5ecdbd77a0eb93061bd
@@ -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)
@@ -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
@@ -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)
@@ -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

0 comments on commit 599b40d

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.