mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-04-18 13:20:59 +00:00
fix cgi output
git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@990 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
parent
83f6c17a27
commit
119d8e2ea7
5 changed files with 33 additions and 21 deletions
|
|
@ -1,7 +1,10 @@
|
|||
1.8.23
|
||||
* upated robotparser.py to python2.3 version
|
||||
* merged robotparser.py with newest official version
|
||||
Changed: linkcheck/robotparser.py
|
||||
Closes: SF bug 784977
|
||||
* start CGI output immediately
|
||||
Changed: lc.cgi, lc.fcgi, lc.sz_fcgi, linkcheck/lc_cgi.py
|
||||
Closes: SF bug 784331
|
||||
|
||||
1.8.22
|
||||
* allow colons in HTML attribute names, used for namespaces
|
||||
|
|
|
|||
6
lc.cgi
6
lc.cgi
|
|
@ -26,5 +26,7 @@ ALLOWED_SERVERS = ['127.0.0.1']
|
|||
#cgi.test()
|
||||
#sys.exit(0)
|
||||
import linkcheck.lc_cgi
|
||||
linkcheck.lc_cgi.checkaccess(hosts=ALLOWED_HOSTS, servers=ALLOWED_SERVERS)
|
||||
linkcheck.lc_cgi.checklink(form=cgi.FieldStorage())
|
||||
linkcheck.lc_cgi.startoutput()
|
||||
if linkcheck.lc_cgi.checkaccess(hosts=ALLOWED_HOSTS,
|
||||
servers=ALLOWED_SERVERS):
|
||||
linkcheck.lc_cgi.checklink(form=cgi.FieldStorage())
|
||||
|
|
|
|||
10
lc.fcgi
10
lc.fcgi
|
|
@ -25,10 +25,12 @@ ALLOWED_SERVERS = ['127.0.0.1']
|
|||
try:
|
||||
while fcgi.isFCGI():
|
||||
req = fcgi.FCGI()
|
||||
linkcheck.lc_cgi.checkaccess(out=req.out, hosts=ALLOWED_HOSTS,
|
||||
servers=ALLOWED_SERVERS, env=req.env)
|
||||
linkcheck.lc_cgi.checklink(out=req.out, form=req.getFieldStorage(),
|
||||
env=req.env)
|
||||
linkcheck.lc_cgi.startoutput(out=req.out)
|
||||
if linkcheck.lc_cgi.checkaccess(out=req.out, hosts=ALLOWED_HOSTS,
|
||||
servers=ALLOWED_SERVERS, env=req.env):
|
||||
linkcheck.lc_cgi.checklink(out=req.out,
|
||||
form=req.getFieldStorage(),
|
||||
env=req.env)
|
||||
req.Finish()
|
||||
except:
|
||||
import traceback
|
||||
|
|
|
|||
11
lc.sz_fcgi
11
lc.sz_fcgi
|
|
@ -22,11 +22,12 @@ import linkcheck.lc_cgi
|
|||
ALLOWED_HOSTS = ['127.0.0.1']
|
||||
ALLOWED_SERVERS = ['127.0.0.1']
|
||||
def func (fcg, req):
|
||||
linkcheck.lc_cgi.checkaccess(out=req.out, hosts=ALLOWED_HOSTS,
|
||||
servers=ALLOWED_SERVERS,
|
||||
env=req.env)
|
||||
linkcheck.lc_cgi.checklink(out=req.out, form=req.getFieldStorage(),
|
||||
env=req.env)
|
||||
linkcheck.lc_cgi.startoutput(out=req.out)
|
||||
if linkcheck.lc_cgi.checkaccess(out=req.out, hosts=ALLOWED_HOSTS,
|
||||
servers=ALLOWED_SERVERS,
|
||||
env=req.env):
|
||||
linkcheck.lc_cgi.checklink(out=req.out, form=req.getFieldStorage(),
|
||||
env=req.env)
|
||||
req.Finish()
|
||||
thread.exit()
|
||||
|
||||
|
|
|
|||
|
|
@ -33,19 +33,23 @@ class FormError (Exception):
|
|||
pass
|
||||
|
||||
|
||||
def checkaccess (out=sys.stdout, hosts=[], servers=[], env=os.environ):
|
||||
if os.environ.get('REMOTE_ADDR') not in hosts or \
|
||||
os.environ.get('SERVER_ADDR') not in servers:
|
||||
logit({}, env)
|
||||
printError(out, "Access denied")
|
||||
|
||||
|
||||
def checklink (out=sys.stdout, form={}, env=os.environ):
|
||||
"""main cgi function, check the given links and print out the result"""
|
||||
def startoutput (out=sys.stdout):
|
||||
out.write("Content-type: text/html\r\n"
|
||||
"Cache-Control: no-cache\r\n"
|
||||
"Pragma: no-cache\r\n"
|
||||
"\r\n")
|
||||
|
||||
def checkaccess (out=sys.stdout, hosts=[], servers=[], env=os.environ):
|
||||
if os.environ.get('REMOTE_ADDR') in hosts and \
|
||||
os.environ.get('SERVER_ADDR') in servers:
|
||||
return 1
|
||||
logit({}, env)
|
||||
printError(out, "Access denied")
|
||||
return 0
|
||||
|
||||
|
||||
def checklink (out=sys.stdout, form={}, env=os.environ):
|
||||
"""main cgi function, check the given links and print out the result"""
|
||||
try: checkform(form)
|
||||
except FormError, why:
|
||||
logit(form, env)
|
||||
|
|
|
|||
Loading…
Reference in a new issue