hgext/lfs/wireprotolfsserver.py
changeset 37766 925707ac2855
parent 37693 31a0d47d69b3
child 38178 3790efb388ca
equal deleted inserted replaced
37765:ab04972a33ef 37766:925707ac2855
   236             yield rsp  # Skip 'actions': already uploaded
   236             yield rsp  # Skip 'actions': already uploaded
   237             continue
   237             continue
   238 
   238 
   239         expiresat = datetime.datetime.now() + datetime.timedelta(minutes=10)
   239         expiresat = datetime.datetime.now() + datetime.timedelta(minutes=10)
   240 
   240 
       
   241         def _buildheader():
       
   242             # The spec doesn't mention the Accept header here, but avoid
       
   243             # a gratuitous deviation from lfs-test-server in the test
       
   244             # output.
       
   245             hdr = {
       
   246                 'Accept': 'application/vnd.git-lfs'
       
   247             }
       
   248 
       
   249             auth = req.headers.get('Authorization', '')
       
   250             if auth.startswith('Basic '):
       
   251                 hdr['Authorization'] = auth
       
   252 
       
   253             return hdr
       
   254 
   241         rsp['actions'] = {
   255         rsp['actions'] = {
   242             '%s' % action: {
   256             '%s' % action: {
   243                 'href': '%s%s/.hg/lfs/objects/%s'
   257                 'href': '%s%s/.hg/lfs/objects/%s'
   244                     % (req.baseurl, req.apppath, oid),
   258                     % (req.baseurl, req.apppath, oid),
   245                 # datetime.isoformat() doesn't include the 'Z' suffix
   259                 # datetime.isoformat() doesn't include the 'Z' suffix
   246                 "expires_at": expiresat.strftime('%Y-%m-%dT%H:%M:%SZ'),
   260                 "expires_at": expiresat.strftime('%Y-%m-%dT%H:%M:%SZ'),
   247                 'header': {
   261                 'header': _buildheader(),
   248                     # The spec doesn't mention the Accept header here, but avoid
       
   249                     # a gratuitous deviation from lfs-test-server in the test
       
   250                     # output.
       
   251                     'Accept': 'application/vnd.git-lfs'
       
   252                 }
       
   253             }
   262             }
   254         }
   263         }
   255 
   264 
   256         yield rsp
   265         yield rsp
   257 
   266