Commit 497dc45a authored by ale's avatar ale

prime the SSO connection with a GET request before the POST

parent 9ae97d6d
......@@ -55,12 +55,21 @@ def process_scan_results(scan_results):
def submit(results, submit_url):
# Run a 'ping' request first, just to make sure that the SSO
# cookie is set *before* we do the POST request (SSO won't work on
# the first connection if it's a POST).
opener = create_opener()
try:
result = opener.open(submit_url).read()
except Exception, e:
log.error('submit(ping) error: %s', e)
return
try:
req = urllib2.Request(
submit_url,
json.dumps(results),
{'Content-Type': 'application/json'})
resp = create_opener().open(req)
resp = opener.open(req)
if resp.status_code != 200:
log.error('submit error: HTTP status %d', resp.status_code)
except Exception, e:
......
......@@ -24,8 +24,11 @@ def before_request():
g.redis = get_redis_connection()
@app.route('/submit')
@app.route('/submit', methods=('GET', 'POST'))
def receive():
if request.method == 'GET':
return ['ok']
p = g.redis.pipeline(transaction=False)
#per_user = {}
for user, results in request.json.iteritems():
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment