Set user agent for commands

master
Bob Mottram 2019-08-26 15:08:41 +01:00
parent dac9f1f5f8
commit 8d6a1e2ffe
2 changed files with 5 additions and 3 deletions

View File

@ -844,7 +844,7 @@ if args.actor:
if nickname==domain:
personUrl=personUrl.replace('/users/','/actor/')
#print('personUrl: '+personUrl)
personJson = getJson(session,personUrl,asHeader,None,__version__,httpPrefix,domain)
personJson = getJson(session,personUrl,asHeader,None,__version__,httpPrefix,None)
if personJson:
pprint(personJson)
else:
@ -854,7 +854,7 @@ if args.actor:
if args.json:
session = createSession(domain,port,True)
asHeader = {'Accept': 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'}
testJson = getJson(session,args.json,asHeader,None,__version__,httpPrefix,domain)
testJson = getJson(session,args.json,asHeader,None,__version__,httpPrefix,None)
pprint(testJson)
sys.exit()

View File

@ -34,7 +34,9 @@ def getJson(session,url: str,headers: {},params: {}, \
if params:
sessionParams=params
pythonVersion=str(sys.version_info[0])+'.'+str(sys.version_info[1])+'.'+str(sys.version_info[2])
sessionHeaders['User-Agent']='Epicyon/'+version+'; +'+httpPrefix+'://'+domain+'/'
sessionHeaders['User-Agent']='Epicyon/'+version
if domain:
sessionHeaders['User-Agent']+='; +'+httpPrefix+'://'+domain+'/'
#"Mozilla/5.0 (Linux; Android 5.1.1; Nexus 5)"
if not session:
print('WARN: no session specified for getJson')