def origin_from_request(request):
 rv = request.META.get('HTTP_ORIGIN', 'null')
 if (rv in ('', 'null')):
  rv = origin_from_url(request.META.get('HTTP_REFERER'))
 return rv

def origin_from_request ( request ) : rv = request . META . get ( 'HTTP_ORIGIN' , 'null' ) if ( rv in ( '' , 'null' ) ) : rv = origin_from_url ( request . META . get ( 'HTTP_REFERER' ) ) return rv
returns either the origin or referer value from the request headers .