|
|
@@ -224,15 +224,16 @@ def add_xff_header(func):
|
|
|
configuration = args[1].__dict__['configuration']
|
|
|
if configuration is not None and 'X-Forwarded-For' in configuration:
|
|
|
xff = configuration.get('X-Forwarded-For')
|
|
|
- try:
|
|
|
- if hasattr(self._oprot.trans, 'TFramedTransport'):
|
|
|
- trans_client = self._oprot.trans._TFramedTransport__trans
|
|
|
- else:
|
|
|
- trans_client = self._oprot.trans._TBufferedTransport__trans
|
|
|
+ if xff:
|
|
|
+ try:
|
|
|
+ if hasattr(self._oprot.trans, 'TFramedTransport'):
|
|
|
+ trans_client = self._oprot.trans._TFramedTransport__trans
|
|
|
+ else:
|
|
|
+ trans_client = self._oprot.trans._TBufferedTransport__trans
|
|
|
|
|
|
- trans_client.setCustomHeaders({'X-Forwarded-For': xff})
|
|
|
- except AttributeError as e:
|
|
|
- LOG.error('Could not set HTTP-X-FORWARDED-FOR header: %s' % smart_str(e))
|
|
|
+ trans_client.setCustomHeaders({'X-Forwarded-For': xff})
|
|
|
+ except AttributeError as e:
|
|
|
+ LOG.error('Could not set HTTP-X-FORWARDED-FOR header: %s' % smart_str(e))
|
|
|
|
|
|
return func(*args, **kwargs)
|
|
|
return wraps(func)(decorate)
|
|
|
@@ -246,15 +247,16 @@ def add_csrf_header(func):
|
|
|
configuration = args[1].__dict__['configuration']
|
|
|
if configuration is not None and 'X-CSRF-TOKEN' in configuration:
|
|
|
csrf = configuration.get('X-CSRF-TOKEN')
|
|
|
- try:
|
|
|
- if hasattr(self._oprot.trans, 'TFramedTransport'):
|
|
|
- trans_client = self._oprot.trans._TFramedTransport__trans
|
|
|
- else:
|
|
|
- trans_client = self._oprot.trans._TBufferedTransport__trans
|
|
|
-
|
|
|
- trans_client.setCustomHeaders({'X-CSRF-TOKEN': csrf})
|
|
|
- except AttributeError as e:
|
|
|
- LOG.error('Could not set CSRF header: %s' % smart_str(e))
|
|
|
+ if csrf:
|
|
|
+ try:
|
|
|
+ if hasattr(self._oprot.trans, 'TFramedTransport'):
|
|
|
+ trans_client = self._oprot.trans._TFramedTransport__trans
|
|
|
+ else:
|
|
|
+ trans_client = self._oprot.trans._TBufferedTransport__trans
|
|
|
+
|
|
|
+ trans_client.setCustomHeaders({'X-CSRF-TOKEN': csrf})
|
|
|
+ except AttributeError as e:
|
|
|
+ LOG.error('Could not set CSRF header: %s' % smart_str(e))
|
|
|
|
|
|
return func(*args, **kwargs)
|
|
|
return wraps(func)(decorate)
|