Skip to content

Commit

Permalink
added cookie transfer request handler
Browse files Browse the repository at this point in the history
  • Loading branch information
martinlovell committed Jan 9, 2020
1 parent 268b813 commit 2462206
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions loris/webapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,10 @@ def _dissect_uri(self):
self.request_type = 'favicon'
return

elif self._path[1:] == 'trans.png':
self.request_type = 'transfer_cookie'
return

#check for image request
#Note: this doesn't guarantee that all the parameters have valid
#values - see regexes in constants.py.
Expand Down Expand Up @@ -435,6 +439,9 @@ def route(self, request):
if request_type == 'favicon':
return self.get_favicon(request)

if request_type == 'transfer_cookie':
return self.transfer_cookie(request)

if request_type == 'bad_image_request':
return BadRequestResponse()

Expand Down Expand Up @@ -500,6 +507,12 @@ def get_favicon(self, request):
r.make_conditional(request)
return r

def transfer_cookie(self, request):
f = path.join(self.www_dp, 'icons', 'favicon.ico')
r = Response(open(f, 'rb'), content_type='image/x-icon')
r.set_cookie("_authorization_cookie", value=request.args['v'], path='/')
return r

def get_info(self, request, ident, base_uri):
try:
info, last_mod = self._get_info(ident,request,base_uri)
Expand Down

0 comments on commit 2462206

Please sign in to comment.