2
0
mirror of https://github.com/WikiTeam/wikiteam synced 2024-11-15 00:15:00 +00:00

Merge pull request #186 from PiRSquared17/update-headers

Preserve default headers, fixing openwrt test
This commit is contained in:
nemobis 2015-03-08 13:56:00 +01:00
commit 2284e3d55e
2 changed files with 4 additions and 4 deletions

View File

@ -1228,7 +1228,7 @@ def getParameters(params=[]):
session = requests.Session() session = requests.Session()
session.cookies = cj session.cookies = cj
session.headers = {'User-Agent': getUserAgent()} session.headers.update({'User-Agent': getUserAgent()})
if args.user and args.password: if args.user and args.password:
session.auth = (args.user, args.password) session.auth = (args.user, args.password)
# session.mount(args.api.split('/api.php')[0], HTTPAdapter(max_retries=max_ret)) # session.mount(args.api.split('/api.php')[0], HTTPAdapter(max_retries=max_ret))
@ -1735,7 +1735,7 @@ def getWikiEngine(url=''):
""" Returns the wiki engine of a URL, if known """ """ Returns the wiki engine of a URL, if known """
session = requests.Session() session = requests.Session()
session.headers = {'User-Agent': getUserAgent()} session.headers.update({'User-Agent': getUserAgent()})
r = session.post(url=url) r = session.post(url=url)
if r.status_code == 405 or r.text == '': if r.status_code == 405 or r.text == '':
r = session.get(url=url) r = session.get(url=url)
@ -1820,7 +1820,7 @@ def mwGetAPIAndIndex(url=''):
api = '' api = ''
index = '' index = ''
session = requests.Session() session = requests.Session()
session.headers = {'User-Agent': getUserAgent()} session.headers.update({'User-Agent': getUserAgent()})
r = session.post(url=url) r = session.post(url=url)
result = r.text result = r.text

View File

@ -167,7 +167,7 @@ class TestDumpgenerator(unittest.TestCase):
def test_getWikiEngine(self): def test_getWikiEngine(self):
tests = [ tests = [
['https://www.dokuwiki.org', 'DokuWiki'], ['https://www.dokuwiki.org', 'DokuWiki'],
#['http://wiki.openwrt.org', 'DokuWiki'], ['http://wiki.openwrt.org', 'DokuWiki'],
['http://skilledtests.com/wiki/', 'MediaWiki'], ['http://skilledtests.com/wiki/', 'MediaWiki'],
#['http://moinmo.in', 'MoinMoin'], #['http://moinmo.in', 'MoinMoin'],
['https://wiki.debian.org', 'MoinMoin'], ['https://wiki.debian.org', 'MoinMoin'],